Need Help! Control commands for the microcontroller.


Results 1 to 11 of 11

Thread: Control commands for the microcontroller.

  1. #1
    Registered
    Join Date
    Apr 2018
    Location
    Ukraine
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default 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.

    Similar Threads:


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2958
    Downloads
    0
    Uploads
    0

    Default Re: Control commands for the microcontroller.

    Hi zaxtone,

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

    Regards



  3. #3
    Registered
    Join Date
    Apr 2018
    Location
    Ukraine
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default 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
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2958
    Downloads
    0
    Uploads
    0

    Default 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);
    }




  5. #5
    Registered
    Join Date
    Apr 2018
    Location
    Ukraine
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default Re: Control commands for the microcontroller.

    a pulse of 1 ms is a logical 0?



  6. #6
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2958
    Downloads
    0
    Uploads
    0

    Default 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



  7. #7
    Registered
    Join Date
    Mar 2015
    Location
    Netherlands
    Posts
    143
    Downloads
    0
    Uploads
    0

    Default 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
    Registered
    Join Date
    Apr 2018
    Location
    Ukraine
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default Re: Control commands for the microcontroller.

    Can KFLOP use UART or I2C?



  9. #9
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2958
    Downloads
    0
    Uploads
    0

    Default 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



  10. #10
    Registered
    Join Date
    Apr 2018
    Location
    Ukraine
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default 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
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2958
    Downloads
    0
    Uploads
    0

    Default 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.



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
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Control commands for the microcontroller.

Control commands for the microcontroller.