• 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.

Oshonsoft Serial DATA

camerart

Active Member
Thread starter #1
Hi,

I have a PCB/program that transmits and receives DATA.
I'm doing a simple radio test between the PCB and a computer Terminal (Termite)
Here is a screen shot of the Terminal, showing the results:.
What do I need to send for the Green COMPDATA to show any result?
Camerart
 

Attachments

camerart

Active Member
Thread starter #3
I thought "Hash" (#) made decimal into ascii

Hserout "Compdata =" , #compdata, crlf
Hi I,
First I tried your suggestion, but it didn't work.
Then I tried a macro which repeats TXing as a GPS would, still no good.
I'll keep checking.
Cheers, C.
 
#5
I think the received compdata is always 0.
Test:
compdata = 65
Hserout compdata ' should see "A" on terminal

And then send 65 from terminal.
Is the 100 you sent decimal number 100 or string " 100" ?
 
Last edited:

camerart

Active Member
Thread starter #6
Have you tested with Hserget?
It reads one byte from rx buffer.
It is 0, if nothing received.
Hi J,
I'm cautious about changing the program without care, as it was mostly written for me, and is beyond my skill level.. Remind me about HSERGET, if the problem isn't solved please.

Here is the program I'm working on at the moment. Much of it has been commented out while I get the last module (Compass) working:

There is a radio connected to the RX TX, of the 18F46K20.

There is a Transmitter sending $????,????,????,???? = 4x SERVOs

Here is the result: (TX)

The first section, is from a serial terminal (Termite) and when connected to the RX PIN, to show the radio is working at the RXPIN.
Below that is from the TX PIN after the program has worked on it. Showing initially it outputs correctly, then RXERR!
[From program]
If RCSTA.OERR = 1 Then 'if over run error then flush RXD buffer
RCSTA.CREN = 0
RCSTA.CREN = 1
char = RCREG
char = RCREG
Hserout "RX Err!", CrLf
Goto skip1
Endif

Watch for errors with commenting out!! or missing cut and pasted lines.

C.
 

Attachments

Pommie

Well-Known Member
Most Helpful Member
#7
Are you allowed to jump out of a if endif construct - your Goto skip1 appears to do this.

Mike.
 
#8
This won't help with rx / tx, but why did you change the servo on times from word to floating point variables ( single) ?
 

camerart

Active Member
Thread starter #10
This won't help with rx / tx, but why did you change the servo on times from word to floating point variables ( single) ?
Hi J,
"This won't help with rx / tx," Is this a response to M?

It's a while ago when the change to SINGLE, I presume it's because WORD didn't work, when testing simulations??
C.
 
#11
Hi J,
"This won't help with rx / tx," Is this a response to M?

It's a while ago when the change to SINGLE, I presume it's because WORD didn't work, when testing simulations??
C.
It is response to you.
The servo code worked perfectly with servo on times as word variables.
 

camerart

Active Member
Thread starter #12
It is response to you.
The servo code worked perfectly with servo on times as word variables.
Hi J,
I see, I read the sentence in a different way.
I remember now, I changed the WORDs to SiNGLEs for future calculations
The SIM has worked all of the time, but the posted results show LIVE.
C.
 

camerart

Active Member
Thread starter #13
Hi,
I did a similar test with BASE transmissions and NMEA sentences also. This sin't how it's supposed to be, but it's a test.

Here is the resulting TX DATA, from Teraterm terminal. It show problems for a minute or two, then after a minute or two started receiving NMEA sentences with calculations. The T=AZ would normally be time.
C.
 

Attachments

#14
Just a comment, I do not like a bunch of Hserin and then 70 Hserout within an Interrupt routine. It defeats the purpose of Interrupts.
This could also complicate or mess up any other Interrupts and related code....
 

camerart

Active Member
Thread starter #15
Just a comment, I do not like a bunch of Hserin and then 70 Hserout within an Interrupt routine. It defeats the purpose of Interrupts.
This could also complicate or mess up any other Interrupts and related code....
Hi S,
The 18F46K20 PIC needs to READ the GPS approx once/sec while receiving DATA from the BASE, then do a calculation and SEND DATA back to BASE while SENDING DATA to the 18LF2520 SERVO control every/20ms. I can ask how you would do this, but then wouldn't be able to start again, I'm afraid, as this is very difficult for me.
C.
 
#16
In #6 Pic18f4620 controls also the 4 servos ( later 6 ) with interrupts of 1-2ms / servo.
I understood that the PIC18LF2520 is just for the servo control?
 
#17
Most common way of using interrupt for receive data is to read the character that did the interrupt, store it in a buffer (array), increment the array pointer. Then, check for any further characters. If none, exit interrupt. If last character received is a form of "end message", you set a flag "receive complete" in the interrupt routine and exit. If flags are already set, ignore received data until main program can process existing buffer array and clear the flags.
Main program then simply loops and checks if the buffer is complete ("receive complete"), and then process the array all at once in main program. Once done processing, clear the "end message" or "full buffer" and reset pointer flags. Same for sending, send from main program loop as interrupts are not necessary for sending data, usually (unless you have special needs to stop the TX data)
 

camerart

Active Member
Thread starter #18
In #6 Pic18f4620 controls also the 4 servos ( later 6 ) with interrupts of 1-2ms / servo.
I understood that the PIC18LF2520 is just for the servo control?
Hi J,

I'm leaving the 18LF2520 till I've got the 18F46K20 working in a test. I'm using a previous 4XSERVO transmitter, I hope this doesn't cause too much confusion. I tried to remove all of the SERVO stuff from the 18F46(K)20, but took too much, this is where I got confused and need to re-check.
C.
 
Last edited:

camerart

Active Member
Thread starter #19
H
Most common way of using interrupt for receive data is to read the character that did the interrupt, store it in a buffer (array), increment the array pointer. Then, check for any further characters. If none, exit interrupt. If last character received is a form of "end message", you set a flag "receive complete" in the interrupt routine and exit. If flags are already set, ignore received data until main program can process existing buffer array and clear the flags.
Main program then simply loops and checks if the buffer is complete ("receive complete"), and then process the array all at once in main program. Once done processing, clear the "end message" or "full buffer" and reset pointer flags. Same for sending, send from main program loop as interrupts are not necessary for sending data, usually (unless you have special needs to stop the TX data)
Hi S,
I will read your examples later, thanks. It will take me a while to follow.

When you look at the existing program, which works in the simulator ok, and maybe was written like this because of Oshonsoft limitations, do you find it unacceptable? The problem is, it was written for me, as it's too advanced for me, but you are welcome to re-write a program, for me to test, as it's too difficult for me.
I am capable of running it in the simulator, and watching the variables and registers, and sometimes spot errors, but I'm careful what I change, in case of unintended consequences.

EDIT: I appreciate your comment at #14 and subsequent explanations, but this project has been developed over years (I'm not quick), so I've decided to get it all working first, then when all of the modules are connected and if it's not satisfactory, alter it then. Thanks.
C.
 
Last edited:
#20
Hi J,
I see, I read the sentence in a different way.
I remember now, I changed the WORDs to SiNGLEs for future calculations
The SIM has worked all of the time, but the posted results show LIVE.
C.
When you mix integer and floating point variables in calculations, the compiled code will be bigger and slower.
I checked the simple calculation in the servo interrupt:
Timr1word = 65535 - t_on
If t_on is a word, it takes 8 instructions and over 30 when t_on is floating point.
If you really need in the future to use floating point on servo times, save and use them with another names, but use integers in the interrupt routine.
 

Latest threads

EE World Online Articles

Loading

 
Top