Output, send Hex to port
Output, send Hex to port
Hello everyone,
I am sending udp data from my pc to the E-blocks internet board.
The data that I am sending is formatted in Hexadecimal. So 01 mean 1 and ff means 255.
Now I want to output this to a E-Blocks LED board, but I don't know how to do this.
I tried to put it into a string and use this in a output block (I know that FC can output hex to a port) but it won't accept a string only a byte.
Is there maybe some easy to to achieve this or should I try to code something up in a C block?
Thank you.
I am sending udp data from my pc to the E-blocks internet board.
The data that I am sending is formatted in Hexadecimal. So 01 mean 1 and ff means 255.
Now I want to output this to a E-Blocks LED board, but I don't know how to do this.
I tried to put it into a string and use this in a output block (I know that FC can output hex to a port) but it won't accept a string only a byte.
Is there maybe some easy to to achieve this or should I try to code something up in a C block?
Thank you.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Output, send Hex to port
Hello,
I am not quite sure whether I understood your problem or not..I have attached here a program in which I have shown three possible data format for output..Binary, Hex or Decimal
I am not quite sure whether I understood your problem or not..I have attached here a program in which I have shown three possible data format for output..Binary, Hex or Decimal
- Attachments
-
- example.fcf
- (5 KiB) Downloaded 610 times
Re: Output, send Hex to port
Well the issue is that I am receiving something through a macro which will write it to a string variable.
Now I want to output this string variable to a port just like you did with 0xFF to port B but now it has to use the string.
And the output block's don't accept a string as a variable.
Now I want to output this string variable to a port just like you did with 0xFF to port B but now it has to use the string.
And the output block's don't accept a string as a variable.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Output, send Hex to port
Output can accept string..like..
Code: Select all
DATA[0]
That's true byte is 8-bit so you can send to port maximum 8-bit. What is the length of your string and how you want to see them in LED? you can show byte-by-byte with some intermediate delay..although LCD is best for this..as you can see whole string at a time.it won't accept a string only a byte.
Re: Output, send Hex to port
The data I have to work with is hexadecimal and goes from 01 to FF.
In total I have 8 leds and want them to switch on or off with the hex data.
So basicly if I send 01 only the first led will go on with 02 the second etc.
If I send 03 I want the first 2 leds to go on all the way until FF.
I already tried to use DATA[0] but It didn't matter what kind of value DATA had.
Only the 1, 5 and 6 led would go on. So it seems like it sended 49 in bytes.
In total I have 8 leds and want them to switch on or off with the hex data.
So basicly if I send 01 only the first led will go on with 02 the second etc.
If I send 03 I want the first 2 leds to go on all the way until FF.
I already tried to use DATA[0] but It didn't matter what kind of value DATA had.
Only the 1, 5 and 6 led would go on. So it seems like it sended 49 in bytes.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Output, send Hex to port
I understand what you mean..Just clear me one thing..I might help you in designing the code. When LED 1,5 and 6 turn ON and it seems to you it sent 49..what actually you sent 1?I already tried to use DATA[0] but It didn't matter what kind of value DATA had.
Only the 1, 5 and 6 led would go on. So it seems like it sended 49 in bytes.
Re: Output, send Hex to port
For that example I used test[0], I think it shouldn't be that hard though I just need to output FF or any other hex value to let the leds switch On or Off
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Output, send Hex to port
If so, just do following..If DATA[0] is your string byte..
In that case DATA[0]= 49-'0' = 49-48 = 1
Send that DATA[0] to PORT so only first LED will turn ON.
If you send 2 it's ASCII will be 50..DATA[0]= 50-48 = 2. So only 2nd LED will turn ON
Code: Select all
DATA[0]=DATA[0]-'0'
Send that DATA[0] to PORT so only first LED will turn ON.
If you send 2 it's ASCII will be 50..DATA[0]= 50-48 = 2. So only 2nd LED will turn ON
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times