Go Down

Topic: LED OOK modulation to send binary information (Read 6091 times) previous topic - next topic

P0lDev

Jul 12, 2013, 10:11 am Last Edit: Jul 12, 2013, 10:55 am by P0lDev Reason: 1
Hey everybody,

I'm working on a project for which I need to send binary information modulated in On-Off Keying (OOK) with an LED. I've found a lot of information about PWM, but very few related to OOK, which is actually simpler than PWM.

So, here's my question: how can I achieve OOK modulation with Arduino? Is it as simple as calling
Code: [Select]
digitalWrite(pin, HIGH) and
Code: [Select]
digitalWrite(pin, LOW) for binary 0s and 1s respectively?

If so, what's the maximum frequency I could get using this method?

Thanks in advance,

Pol

fungus

If you access the ports directly you can change the state of the output in a single clock cycle. On a 16MHz Arduino you can output an 8MHz square wave.

The difficulty is going from "output square wave" to "send binary information".
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Riva

Most weather station sensors use a 433Mhz wireless module that sends data using OOK so finding some examples of how they define 0 & 1 bits may be helpful and then substitute a LED for the RF module. I have attached the output of one such sensor. The long off hook is to signal the start of the message and then short off hooks are one's and longer are zero's. The signal is pulsed high for a short period between bits.
Don't PM me for help as I will ignore it.

P0lDev


If you access the ports directly you can change the state of the output in a single clock cycle. On a 16MHz Arduino you can output an 8MHz square wave.


Thanks for answering that fast. Could you explain a little bit more on the topic? I'm pretty new to Arduino.


The difficulty is going from "output square wave" to "send binary information".


Though I'm not sure how to do this in Arduino (yet), I believe one way to do it would be to place the binary information in an array.
Then, I could read the array element-by-element, generating the "output square wave" with some condition.

Do you know the syntax to do so?

Regards,

Pol

P0lDev


Most weather station sensors use a 433Mhz wireless module that sends data using OOK so finding some examples of how they define 0 & 1 bits may be helpful and then substitute a LED for the RF module. I have attached the output of one such sensor. The long off hook is to signal the start of the message and then short off hooks are one's and longer are zero's. The signal is pulsed high for a short period between bits.


Thanks for the answer. Do you know any examples of one of these weather station sensors?

Regards,

Pol

AWOL

Google only lists 49 900 results for "Arduino Weather station OOK"
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

fungus



The difficulty is going from "output square wave" to "send binary information".


Though I'm not sure how to do this in Arduino (yet)


The same way as you'd do it in any other device.

IR remote controls are a good example of OOK. Use Google to find out how they transmit binary information to a TV.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

P0lDev

Thanks to all of you for your answers.


If you access the ports directly you can change the state of the output in a single clock cycle.


Before moving forward into "sending the actual binary information", I have to understand the basis of creating the output square wave.
What do you mean by "being able to access the ports directly"?

Regards,

Pol

fungus


Before moving forward into "sending the actual binary information", I have to understand the basis of creating the output square wave.


It's not necessary, the two things aren't linked.


What do you mean by "being able to access the ports directly"?


It's just the fastest possible way to do "digitalWrite()".

http://www.arduino.cc/en/Reference/PortManipulation
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Riva

#9
Jul 12, 2013, 02:22 pm Last Edit: Jul 13, 2013, 03:28 pm by Riva Reason: 1
Untested code but the basic idea would be something like this...
Code: [Select]
const char message[] = {"Hello!"};
const byte outPin = 13;
const int beginDelay = 100;
const int zeroDelay = 50;
const int oneDelay = 25;
const int bitDelay = 10;


void setup() {
 Serial.begin(9600);
 pinMode(outPin,OUTPUT);
}

void loop() {
 digitalWrite(outPin,LOW);
 delay(beginDelay);
 Serial.println("Delay");
 for(int x = 0; x < sizeof(message) - 1; x++) {
   char a = message[x];
   Serial.print(x);
   Serial.print(" ");
   Serial.println(a);
   for (int y = 0; y < 8; y++){
     byte z = (a >> y) & 1;
     Serial.print(z);
     digitalWrite(outPin,HIGH);
     delay(bitDelay);
     digitalWrite(outPin,LOW);
     if (z == 0){
       delay(zeroDelay);
     }
     else {
       delay(oneDelay);
     }
   }
   Serial.println();
 }
 digitalWrite(outPin,HIGH);
 delay(bitDelay);
 digitalWrite(outPin,LOW);
 Serial.println("Finished.");
 while(1){
 }
}


EDIT: Added LA sample from above code.
Don't PM me for help as I will ignore it.

P0lDev

Hello everyone,

It turns out that the other day, with all the #ArduinoDay stuff I was reminded of this forum. So... first things first, I'd like to thank you all for helping me write the code for the project I was working on at the time.

In the end, I got everything to work kinda perfectly with the following setup: two Arduinos, one with 2 LEDS, the other with 2 photodiodes, and each connected to a different laptop. When I write a text message in one of the laptops, it's converted into ASCII binary and sent through an OOK modulation to the second board, which transforms the string back to text, showing the original message in the second laptop. The secondary LEDs and photiodes establish the comm protocol, such that the comm channel is kept open while the 2nd photodiode receives a constant signal from the 2nd LED.

Anyway, attached are the final code sketches for both the transmitter ("textSend.ino") and the receiver ("textRead.ino") and, in case you are interested in the topic, here's the research project I wrote (whose experimental results are based on the Arduino project): http://coderagora.com/docs/research/

Thanks!

-- Pol

lastreez

#11
Nov 24, 2015, 03:00 pm Last Edit: Nov 24, 2015, 03:28 pm by lastreez
Hi, i saw your project and i worked on something similar but now i am working on V2V using LEDs i was wondering if we could exchange information! Peace Ps if is possible i will leave you my contact here, just say something, thanks!

Paul__B

When I write a text message in one of the laptops, it's converted into ASCII binary and sent through an OOK modulation to the second board, which transforms the string back to text, showing the original message in the second laptop.
Sounds like a marvellously obscure way to do something you could do via WiFi. :smiley-lol:

The secondary LEDs and photo-diodes establish the comm protocol, such that the comm channel is kept open while the 2nd photo-diode receives a constant signal from the 2nd LED.
Again, a rather involved way to do things.

The trick on a digital channel, is to merge supervisory ("2nd channel") information with the main stream.  This is generally performed as part of the verification process, by using "sync" characters, "escape" sequences and sending data in "packets" with checksums.

In other words, if the channel is idle, you send a continuous stream of SYN characters (of some sort); when you have some actual data to send, you start a packet with a marker, size, the data and a checksum, close with more SYN and "escape" any SYN character appearing within the data.

The SYN stream of course verifies when the channel is "up".

AinaRd

POIDev I am really intertested in your project, will it work with an LDR?

Paul__B

Hmm, OP not been on forum for 4½ years, did not respond to lastreez' enquiry ... I don't think you are likely to get an answer.

So maybe I will give you one.

No, it won't.

Go Up