Hi zaxtone,
You would need to explain more completely what you wish to do.
Regards
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:
Hi zaxtone,
You would need to explain more completely what you wish to do.
Regards
Regards
TK http://dynomotion.com
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.
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); }
Regards
TK http://dynomotion.com
a pulse of 1 ms is a logical 0?
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
Regards
TK http://dynomotion.com
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.
Can KFLOP use UART or I2C?
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
Regards
TK http://dynomotion.com
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?
Hi zaxtone,
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.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?
Not necessarily, but that would depend on your requirements and if you wish to detect errors.Should ATMEGA128 acknowledge receipt of a command? Do I need any more feedback?
Regards
TK http://dynomotion.com