Transmitter Data ERF and using the OLED

Tesla

Member
Hi there Folks

Well, after several days of studying code and samples, I have conceded to the fact that I need help!
Here is a brief run down of what I am trying to do.

I have two ERFs connected to two O8M2 protoboards

I am trying to transmit a numerical value from one to the other and as I have connected a LED to indicate (DTR on the ERF) of transmit and receive I know that they are talking to each other successfully? as if I stop the TX, the LED on DTR stops flashing on the Receiver. I have tied the RX to Ground on the Receiver.
Also on the Receiver I have "serout " going to an OLED screen.

Now if I disable the Serin command line on the receiver code, the chip drives the screen successfully and displays the (output=35) It appears that this line is locking the code somehow? This is without transmitting anything or receiving, so I know the rest of the code is OK. I presume this stops all the code until it receives the correct data?

For some strange reason if I leave this line "SERIN. .. . . ." active, the screen just starts producing strange characters all over the place, I have tried different frequencies, so puzzled. .??

I cannot seem to capture data send and display it successfully. This is the main problem!
I have seen different code examples, some with the #, some without, some data in () some with preamble or "ABC" etc. ..So now stuck after 3 days of studying, hoping someone can point me on the right direction. .?

What I wish to do is simply transmit Numerical data from one ERF to another and display on the OLED!

Any Help would be appreciated. :)

Tesla
Code below
Code:
'Transmit from one pixaxe to another NOTE this is using transmits the number 5
init:	low C.0
	pause 1000
	 'seeded value	
main:	Setfreq M16
	serout C.0, N9600_16, (#5,"X") ' x tells the reciever its finished with numerics?
	Low C.0 'might mean that it stops sending?
	pause 1000
	goto main

'RECIEVER Via ERF
'#picaxe 8M2
#terminal 9600


init:	'LOW C.0 ' C.0 port that sends serial out 
	pause 100
	'MOTE THE SERIN line below must recieve data or program cannot proceed
	'Receiver Code and output to screen

	symbol AR = b6
	AR = 35
	symbol BR = b7
	
main:	Setfreq M16
	pause 100
	serin C.5, T9600_16,b6 ' NO "#",captures data from serial in pin 2 (C.5) from RF reciever
'======================================================================
' OUTPUT TO OLED SCREEN

'======================================================================

Setfreq M4 'set frequency for screen out to 4 Mhz so that baud is 2400, if left at 16mhz it defaults to 9600
	pause 100
	serout C.0, N2400, (254,1) 'clear screen
      pause 200
      serout C.0, N2400, (254,128) ' move to postion 1 line 1
      pause 200
      serout C.0, N2400, ("output = ",#AR,CR,LF) 'send value w1 to screen
      goto main
 

Tesla

Member
My Apologies..

Why is N9600_16 used for transmitting but T9600_16 used for receiving?
Hi there
My Apologies, I have tried both in the editor and and not updated the notepad. .on the TX and the RX . .my mistake, but this is not the problem. .well spotted ..!
OK I have shortened the code as this may be able to make it easier to follow and changed it to what I believe to be correct after reading everything .

Again, its showing it receiving the data, but will not display it correctly??? just rubbish . .?

Code:
 'Transmitter
 start:      Setfreq m8
               Goto main
 main:     serout C.0, N9600_8,(#5,"X") 'tried N and T ? 
               pause 500
 	  Goto Main
 '-------------------------------------------------


'Receiver RX
 main:   Setfreq m8
             serin C.5, N9600_8,B0
             if B0 =5 then
             Setfreq m4
             serout C.0, N2400, ("output = ",#B0,CR,LF) 'send value w1 to screen 
             Endif
             pause 500
             Goto main
 
Last edited:

nick12ab

Senior Member
Does it still display the output = bit on the LCD? If so, then it's because you're using # twice. Using # once converts a number into ASCII and for a byte variable one, two or three ASCII bytes could then be sent depending on the magnitude of the number. Using # a second time will not achieve the desired outcome. You should remove the # from the transmitting PICAXE's serout and use it only for the serial LCD.
 

Tesla

Member
According to the ERF data sheet it state that they default to N9600_8 so set the code both to this parameter.
In the receiver I change the Frequency to M4 to write to the OLED at 2400- -!
In the Pic Editor when I simulate it it seems to work , it asks for SERIN value, I enter 5,"X" ( the x to tell the numerics have ended) and it outputs " Output = 5
When I connect everything up it displays the welcome message on the OLED correctly
After a second or two the transmitter shows heartbeat and transmit LED every half second or so..
The receiver unit shows Heartbeat and RX LED light flashing at same rate.
BUT
The output on the screen keeps the WELCOME message and starts writing over certain characters with complete rubbish.
If I unplug the TX, its stops this.

Conclusion its transmitting and receiving but not capturing correct DATA ( the numerical Value 5) ?

I must be missing something that is obvious to someone ..?
 

nick12ab

Senior Member
If you replace the serin line in the receiver code with a short pause (pause 100) without removing the setfreq commands, what does the display display?
 

Tesla

Member
It appears to be that the data I am transmitting is not a numerical value , but could be a character code number?
I am guessing that the Serin command could collecting garbage or cannot escape as I know the program hangs at this point. .

could it be that I am using 08m2 chips?

I had a previous problem using these with the pause statement, but found that using multiples of 20ms worked for some reason. .

I am gathering info and outputting info at the same time??
 

Tesla

Member
just the original built in display logo picaxe.com etc.. .!
Nothing else. . .but when the TX isconnecting again, the same rubbish starts overlaying the logo on the screen!
Same problem as before.. .
Thanks with the suggestions by the way, any help is appreciated.. spent hours and hours on this.. !
 

nick12ab

Senior Member
What exactly is this rubbish? Are you sure it isn't the text output = , which will appear in this way due to the OLED not being told to go back to the beginning of the line before displaying the text?
 

Tesla

Member
The main issue is that the SERIN line in hanging or stopping the program, it does not progress to even
OUTPUT = %&%&%¤ rubbish!
It hands with the PICAXE LOGO and overwrites it with rubbish ..only in the corner bottom right 4 characters of the screen and the top line.
BUT
The screen works perfectly if I remove the SERIn line. .?
 

Tesla

Member
Its rubbish,because it starts with bottom line far right , the very last 2 characters, then it does the last 4 characters. .then the top line completely in a strange character
its like an " o" with a wiggle on the top- -
In the character Table for the OLED its
Lowercase HHHL
UPPECASE HHLL

Similar to this character
Õ

. ..
 

nick12ab

Senior Member
What happens if you keep the serin command there but use this code at the very beginning of the receiver code?
Code:
low C.0
 

Tesla

Member
What happens if you keep the serin command there but use this code at the very beginning of the receiver code?
Code:
low C.0
Same problem as before...?
'Receiver RX
main: Setfreq m8
Low C.0

serin C.5, N9600_8,B0
if B0 =5 then
Setfreq m4
serout C.0, N2400, ("output = ",#B0,CR,LF) 'send value w1 to screen
Endif
pause 500
Goto main
 

nick12ab

Senior Member
Unfortunately I cannot see how the addition of the serin command makes the difference between the OLED working and not working.

Have you got decoupling capacitors fitted?
 

Tesla

Member
Try this yourself in the Picaxe Editor
It asks for Serin
Enter 5,"X"
Then it displays SERIAL LCD
Output = 5

But when I try it with hardware, it does not work ?
Receiver RX
main: Setfreq m8
Low C.0
pause 8000
serin C.5, N9600_8,B0
if B0 =5 then
Setfreq m4
Low C.0
pause 8000
serout C.0, N2400, ("output = ",#B0,CR,LF) 'send value w1 to screen
Endif
pause 500
Goto main
 

nick12ab

Senior Member
In the transmitter code change this:
serout C.0, N2400, ("output = ",#B0,CR,LF)
to this:
serout C.0, N2400, (254,128,"output = ",#B0," ")

Is this the exact transmitter code?
Code:
start:      Setfreq m8
               Goto main
 main:     serout C.0, N9600_8,(5,"X") 'tried N and T ? 
               pause 500
 	  Goto Main
 

Technical

Technical Support
Staff member
Why is your transmitter sending this?
serout C.0, N9600_8,(#5,"X")

To send the value 5 you shouldn't use #. Just use
serout C.0, N9600_8,(5,"X")
 

Tesla

Member
OK Technical, but when I run it in the PicAXE simulator this spits out |X|X|X|X
but when I put the # in front it spits out
5X5X5X
I trust you, but question why? :)
 

Tesla

Member
Hi Nick,
Also changed the serin line. ., still same problem.. ?
But in the hardware, I still see that the TXand RX LED indicators are lighting, so TX and RX is working ..?
The plot thickens, or maybe its just me thickening .
:)
 

Tesla

Member
Hi Nick
Now WE have something, ,, but value only 0?
OK
Now it outputs
OUTPUT = 0 &&&&&&&&&&
UTPUT = 0 &&&&&&&&&&&
Alternating. ..
with the following code
'Receiver RX
main: Setfreq m8
serin C.5, N9600_8,B0
if B0 =5 then
Setfreq m4
serout C.0, N2400, (254,128,"output = ",#B0," ")
Endif
pause 500
Goto main

and the amendment that Technical suggested removing #
 

Technical

Technical Support
Staff member
Your posts are a bit erratic but if we understand correctly your receiver is on C.5, the serial programming input on an 08M2.
If this is the case you must
1) add a disconnect command at the start of your program
2) use the hard-reset procedure for new downloads

At present your chip is resetting every time the transmitter sends something (as you have not added a disconnect command).
 

Tesla

Member
Code now as follows..
Code:
' 'Transmitter
 start:        Setfreq m8
                 Goto main
 main:         serout C.0, N9600_8,(5) 
                 pause 500
 	         Goto Main

Code:
'Receiver RX
 main:       Setfreq m8
               serin C.5, N9600_8,B0
               Setfreq m4
               pause 100
               serout C.0, N2400, (254,1) 'clear screen
               serout C.0, N2400, (254,128,"output = ",#B0,"      ") 
               pause 100
               Goto main
Now thanks to Nick and Technical, we are now transmitting the number 5 across the room, now to build the Astronauts Spacesuits and we will have lift off
So the problem seemed to be the position of the serial positioning on the OLED as highlighted By Nick and sending the Data as the correct format ..which Technical spotted.. .
Thanks guys. .Your help is very much appreciated and I hope the code will help others..
 

boriz

Senior Member
As a precaution, I usually add a small delay after any SETFREQ commands to allow the new frequency to settle before any timing crucial commands like SEROUT or SERIN etc.
 
Top