585,728 active members*
4,471 visitors online*
Register for free
Login
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2018
    Posts
    15

    Control commands for the microcontroller.

    Hi!
    I want to use a microcontroller to control some devices. I want to use 9 pins. It is necessary that on each output there are 3 different commands that the microcontroller could recognize. In my case, this is Atmega128.
    What kind of g- m-codes it can be implemented? Write on the example output IO30.

  2. #2
    Join Date
    May 2006
    Posts
    4045

    Re: Control commands for the microcontroller.

    Hi zaxtone,

    You would need to explain more completely what you wish to do.

    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Apr 2018
    Posts
    15

    Re: Control commands for the microcontroller.

    Let's assume from the output of the IO30 can control the microcontroller with three different commands. "FORWARD, STOP and BACK".
    Assume for each command a specific set of 0 and 1 that the microcontroller could recognize it as one of three commands.

  4. #4
    Join Date
    May 2006
    Posts
    4045

    Re: Control commands for the microcontroller.

    Maybe pulse 1ms for FORWARD, 2ms for STOP, 3ms for BACK ? Your microprocessor would need to time the pulse in order to determine what it should do.

    ie.

    Code:
    void STOP(int bit)
    {
        SetBit(bit);
        Delay_sec(0.002);
        ClearBit(bit);
    }
    TK
    http://dynomotion.com

  5. #5
    Join Date
    Apr 2018
    Posts
    15

    Re: Control commands for the microcontroller.

    a pulse of 1 ms is a logical 0?

  6. #6
    Join Date
    May 2006
    Posts
    4045

    Re: Control commands for the microcontroller.

    Hi zaxtone,

    I don't really understand the question.

    But no. In my suggested approach only one pulse would be needed. The measured time period would fully represent the command code.

    I suppose an alternate approach might use a 1ms pulse for logical 0 and a 2ms pulse for logical 1. Then send a set of multiple pulses to form a multi-bit command code. You would probably also need a method of identifying the start bit.

    Regards
    TK
    http://dynomotion.com

  7. #7
    Join Date
    Mar 2015
    Posts
    409

    Re: Control commands for the microcontroller.

    If you have nine pins then you could use one for the clock, 4 for the address and 4 for the command. This way you could control 16 devices by 16 commands.
    The microprocessor reads the address and command on every clock transition from High to Low.

    It is also possible to use just 2 pins (clock and data) to control any number of devices and commands. The i2C protocol works like this and many display controllers use just 2 pins. It is a lot easier to read the data on the change of a clock pin, than timing the level change of a pin.

  8. #8
    Join Date
    Apr 2018
    Posts
    15

    Re: Control commands for the microcontroller.

    Can KFLOP use UART or I2C?

  9. #9
    Join Date
    May 2006
    Posts
    4045

    Re: Control commands for the microcontroller.

    Hi zaxtone,

    KFLOP has a UART. See here

    No I2C.

    SPI can be performed in software at ~450Kbits/sec. See the SPI V6.c example

    Regards
    TK
    http://dynomotion.com

  10. #10
    Join Date
    Apr 2018
    Posts
    15

    Re: Control commands for the microcontroller.

    1.Can the data transfer in the proposed format ?: For example, the first byte 170 is the starting byte, then the command byte is for example 2, then the final byte, for example 204?
    2. Should ATMEGA128 acknowledge receipt of a command? Do I need any more feedback?

  11. #11
    Join Date
    May 2006
    Posts
    4045

    Re: Control commands for the microcontroller.

    Hi zaxtone,

    Can the data transfer in the proposed format ?: For example, the first byte 170 is the starting byte, then the command byte is for example 2, then the final byte, for example 204?
    You would need to explain more completely what you are trying to do. But I suppose that would work. I was assuming you wanted to control many devices not just one.

    Should ATMEGA128 acknowledge receipt of a command? Do I need any more feedback?
    Not necessarily, but that would depend on your requirements and if you wish to detect errors.
    TK
    http://dynomotion.com

Similar Threads

  1. KFlopWebNC M commands and 8 axis control
    By MikeMz3 in forum Dynomotion/Kflop/Kanalog
    Replies: 3
    Last Post: 03-06-2015, 06:57 AM
  2. DC Servo quadrature control using microcontroller
    By Richotech in forum PIC Programing / Design
    Replies: 4
    Last Post: 08-03-2010, 04:54 AM
  3. New to microcontroller
    By rainman in forum PIC Programing / Design
    Replies: 1
    Last Post: 03-19-2009, 04:08 PM
  4. Thread commands on 6T control
    By Ricardo Guedes in forum Fanuc
    Replies: 2
    Last Post: 02-03-2006, 07:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •