Heya folks! I am trying to send a signal to an adjustable desk controller, and to do that I need to send a couple binary values out. I am attempting to clone what a controller is doing, which is a series of off and on signals at 100us each.
For example, I would want to send out [0 1 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0] with each bit lasting 100us each.
I could do a dirty method of creating an array, setting HIGH or LOW the pin depending on the value, but even the delay() function can only go at 1ms, and that includes the processing time of the loop and digital write function.
Any thoughts on how I can send a patterned pulse, like above, at the timing I am seeking?
void loop(){
Code to wait for input waiting to know what code to send
//function for sending pulses:
reset micros() somehow
for(not gone through entire array of numbers){
while (micros < 40us * stage of array) {loop here}
digitalwrite (value of current stage of array)
}
It is sending out 4 binary numbers, the first 3 declare the type of desk, and the last is the height. I don't have a serial communication module to the controller, so trying to do it over a pinout. I have looked up how others have done this, or at least their analysis of the data being sent, and confirmed using an oscilloscope. Unfortunately I don't have a tech or spec sheet for the controller.
There's nothing wrong with just using delayMicroseconds().
Put the bit on the pin, delay, repeat.
The exact delay factor might need a bit of tweaking, but the inter-bit overheard time should be very consistent, so delay should be able to time pout the sequences.
Can you share links to the device to be controlled, and any useful sites that have hacked or attempted to hack this?
Looking at this:
I can't help but wonder if it's just 8 bit serial, no parity. You can see what looks like a repeating stop bit. What is the exact pulse width (again?).
Approx 100us, more likely 104us. It's default value is high, with this value code you posted coming after 3 other values declaring what I assume is limit / max values. It is a consistent pattern followed by the pulse pattern.
Tomorrow (no more time today to do computer stuff) I will mess with it, make a test code, and see what happens!
The sender is always allowed to stay in stop state (HIGH = idle) as long as it wants.
"Two stop bits" means the receiver needs such a pause to deal with the complete byte, and the sender has to wait that time before it is allowed to switch to LOW to signal the start bit.
Haven't gotten to syncing, but will cross that bridge when I get there.
Is there a guide I can follow to send UART values out of the Tx pin? Wanting to keep from having to use additional hardware, just want to give a value and have it sent out to the controller from the Arduino.