• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

TX RX HC-12 radio module

#21
Hi I,
Anything to save me remembering stuff is welcome.

TX is sending "0" or "1" depending on a BUTTON press, and can be seen on my terminal
RX turns on RLED or YLED depending on TX "0" or "1" but needs to be reset to change.
RX LEDs don't always come on after reset, approx 50%, but if they do they are the correct colour

RX CODE---------------------------------------------------------------------------------
main:
Hserget i
If i = Asc("0") Then '< --- -- 48 is number 0
Hserout "Number: ", i, CrLf
rled = 1
WaitMs 500
Endif

If i = Asc("1") Then '< --- -- 49 is number 1
Hserout "Number: ", i, CrLf
yled = 1
WaitMs 500
Endif
Goto main
Maybe I don't understand what you want to do with the leds,
but you have no code in rx to set rled = 0
 

camerart

Active Member
Thread starter #22
There are hundreds of ASCII tables online to check the relating numbers..

But!! I imagine this is for testing, because you can't easily send non ascii characters from a PC..


Yeah!! Sorry about that... I tested it with "If i = 48 then" Hey! with help like mine you are definitely kept on your toes!!
Hi I,
As long as we get there in the end, that's fine.
C.
 

camerart

Active Member
Thread starter #23
There are hundreds of ASCII tables online to check the relating numbers..

But!! I imagine this is for testing, because you can't easily send non ascii characters from a PC..


Yeah!! Sorry about that... I tested it with "If i = 48 then" Hey! with help like mine you are definitely kept on your toes!!
Hi J,
I've used rled = 0 yled = 1 and rled = 1 yled = 0 in the past, I'll add it back in, but the problem is: they are OFFing, but not ONing. Although if they come ON, they don't switch off till TX SENDs a '0' is and RX is reset.

I think it's something to do with timing of the HSERGET.

I have an ASCII table, but probably only need 0 to 9, for playing with.
C.
 

camerart

Active Member
Thread starter #24
Hi,
Failed! I can only get the RX to switch, if I reset the PIC. Here's what I used:
There is a more complex version on AAC, which I'm gouing to try now. I've used similar before, and it is very versatile.
C.
TX'--------------------------------------------------------------------------------------------
main:
If button = 1 Then 'BUTTON NOT PRESSED
rled = 0
yled = 1
Hserout "0", CrLf
Endif
WaitMs 500

If button = 0 Then 'BUTTON PRESSED
rled = 1
yled = 0
Hserout "1", CrLf
Endif
WaitMs 500

Goto main
RX------------------------------------------------------------------------------------------------
main:
Hserget i
WaitMs 500
If i = Asc("0") Then '< --- -- 48 is number 0
Hserout "Number: ", i, CrLf
rled = 0
yled = 1
WaitMs 500
Endif

If i = Asc("1") Then '< --- -- 49 is number 1
Hserout "Number: ", i, CrLf
rled = 1
yled = 0
WaitMs 500
Endif
Goto main
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#25
I am struggling here C...

If you press ( And keep it pressed ) red should light and yellow should go out and when you let go ,the leds should reverse..???

Why are you sending ("number: " i,CrLf ) back to the transmitter.. If you don't deal with the reception in the transmitter the serial port will overun!!
 

camerart

Active Member
Thread starter #26
I am struggling here C...

If you press ( And keep it pressed ) red should light and yellow should go out and when you let go ,the leds should reverse..???

Why are you sending ("number: " i,CrLf ) back to the transmitter.. If you don't deal with the reception in the transmitter the serial port will overun!!
Hi I,
Why are you sending ("number: " i,CrLf ) back to the transmitter? Only so I can see it in the computer terminal as a check. It's not necessary really.

PORT overruning! How do I stop this?
C.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#27
If you use that code on your Tx board and not the PC, the serial port in the pic will receive the string but the port will not be read, This will cause the OERR flag to be set and the port will need a reboot! The terminal program on the PC will do it automatically..
 

camerart

Active Member
Thread starter #28
If you use that code on your Tx board and not the PC, the serial port in the pic will receive the string but the port will not be read, This will cause the OERR flag to be set and the port will need a reboot! The terminal program on the PC will do it automatically..
Hi I,
Aha!
As the computer terminal is just for monitoring, it can be ignored.
Is there a way to reset the OERR flag, so the TX can keep READing?
C.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#34
Hi All,
I chose to use a more complex but versatile program, from another forum ETO, from Eric Gibbs
Here are both of them:
Thanks to everyone who helped.
C.
Yeah! I know... I've been watching!! As long as you get there, That's all that matters..
 

camerart

Active Member
Thread starter #35
Hi I and J,
If you would like me to carry on getting this simpler program to work for your satisfaction, I'll carry on, but for my purposes, the #33 programs are better.
C.
 

camerart

Active Member
Thread starter #37
Eric's programs normally work, so They would be the ones to build on... As you know, I use C so any basic program we develop would only be for others on this forum!!
Hi I,
Very true. I've been playing with them, and they're working ok, apart from changing frequency. I'm just about to start a post regarding this.
C.
 

camerart

Active Member
Thread starter #38
Hi,
Here are a couple of programs, that I've modified, to be TX with RX ECHO, for use to test antennas.
They aren't perfect, and need to TX to be RESET for a result.

Switch on RX and TX, then move the TX away from the RX, while RESETTING the TX with either the BUTTON pressed or not. If pressed and they are in range, then a signal goes to the RX and it sends asignal back to the TX, which switches a LED on.
Hope it's useful.
C.
 

Attachments

Latest threads

EE World Online Articles

Loading

 
Top