Continue to Site

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.

  • 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

Status
Not open for further replies.

camerart

Well-Known Member
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

  • Serial IN-OUT.jpg
    Serial IN-OUT.jpg
    167.3 KB · Views: 247
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.
 
Have you tested with Hserget?
It reads one byte from rx buffer.
It is 0, if nothing received.
 
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:
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

  • 18LF4620 32Mhz RX 2XPIC COMPASS HC-12 070918 1800.bas
    19.9 KB · Views: 217
  • TX.txt
    23.4 KB · Views: 231
Are you allowed to jump out of a if endif construct - your Goto skip1 appears to do this.

Mike.
 
This won't help with rx / tx, but why did you change the servo on times from word to floating point variables ( single) ?
 
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.
 
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.
 
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.
 
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

  • TX.txt
    4 KB · Views: 221
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....
 
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.
 
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?
 
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)
 
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:
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:
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top