sensor problem

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
aerofrick
Posts: 23
Joined: Mon Mar 08, 2010 4:37 pm
Location: Slovenia
Has thanked: 2 times

sensor problem

Post by aerofrick »

Hi!

I have one (or two :D) problem(s).
For my own project I am making (in Flowcode V4) device which measures temperature and humidity. This two physical quantities I displays on LCD and min/max values for this two quantities too. OK, this work very well ;)
I am trying to measure outdoor temperature and humidity too, and I am trying to use 433.92MHz remote modules, but I don't know which communication I can use for communicate transmitter->PIC and on the side receiver->PIC…maybe SPI, I2C or something similar?
And here is a second problem…I am reading this two values as INT value (0-1023), so in 10bit »mode«… how can I send this 10 bits? Maybe I must distribute this before transmitting in two 8 bits »packets« and on the side I must combine it?

Do you have any example project with using RF modules in program?

Thanks for all!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: sensor problem

Post by Benj »

Hello,

We plan to do some work on RF modules soon but so far I dont have any examples I can hand out.

You should be able to use the UART eg the RS232 component in Flowcode. This will let you send 8-bit characters across to the remote device.

To convert 16-bit INT variable into two bytes for transmitting you would do the following.

byte1 = int1 & 0xFF
byte2 = int1 >> 8

then transmit byte 1 and byte 2.

To recombine the values simply reverse the process.

int2 = byte2 << 8
int2 = int2 | byte1

aerofrick
Posts: 23
Joined: Mon Mar 08, 2010 4:37 pm
Location: Slovenia
Has thanked: 2 times

Re: sensor problem

Post by aerofrick »

Thanks!

Ok, so now…I took RS232 component… From one INT variable, I made two BYTE variables round your prescription, but…in Send mode (RS232), I can chose SendRS232Char (INT) or SendRS232String. STRING I can't use for BYTE variable, but If I use INT, then I get only ******* in RS232 component (Characters send)?
How »big« must be delay between sending one and then second BYTE, maybe do you know? (now I chose 200ms between two BYTE variables of one physical quantity, and 1s between sending two BYTE variables of second physical quantity)
Hm…and how can I set baudrate <1200, for example 300 (because I read that for RF component is advisably to use slow baudrate, for start)?
And maybe last question for now…how to set that the other PIC (where I have reciever) will know when the correct »information« is comming?

Thanks!

PS: Ok, If I use 20MHz crystal I can't chose 300 baudrade, but if I use 4MHz crystal than I can chose 300 baudrate, so I will use 4MHz
rs232.fcf
(8.5 KiB) Downloaded 328 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: sensor problem

Post by Benj »

Hello,
in Send mode (RS232), I can chose SendRS232Char (INT) or SendRS232String.
Use the SendRS232Char macro to send your byte variables. A 9-bit integer variable is allowed to be entered if you are running the RS232 in 9-bit mode. By default the 8-bit mode will be selected which is correct for what you require.
but If I use INT, then I get only ******* in RS232 component
This is normal. If the characters you are sending are not ASCII data which they are not. You can edit the component properties to show Bytes instead of characters in the simulation and this should show the data better.
Hm…and how can I set baudrate <1200
1200 is a very low baud rate. I would also classify 2400 and 4800 as fairly slow baud rates if this helps. You method of using a smaller crystal will also work to allow for a smaller baud rate.
how to set that the other PIC (where I have reciever) will know when the correct »information« is comming?
The RS232 uses a method of 1 start bit and 1 stop bit to start and end a RS232 transaction. The RS232 component looks for these and will only say that a byte has been received when a correct sequence is received.

aerofrick
Posts: 23
Joined: Mon Mar 08, 2010 4:37 pm
Location: Slovenia
Has thanked: 2 times

Re: sensor problem

Post by aerofrick »

Ok, I made program for two PIC's (one for transmiting and one for receiving data). Transmiting from "transmiting" PIC is OK which I saw in Pickit2 UART tool, but on the other side (in "output" of recever It gave me a lot of "noise" (saw in Pickit2 tool). Maybe, betwen this noise is data which I transmited, but how can I detect this data?
Can you see my two Flowcode projects (one for transmit and one for recieve, if they are ok, please?

Thanks
433_92_tr.fcf
(8.5 KiB) Downloaded 326 times
433_92_rc.fcf
(9 KiB) Downloaded 282 times

Post Reply