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.

Add GPS/PARSE to 8xSERVO-MOTOR CODE in Oshonsoft

Where should I put the PARSE and rest of the CODE?
Put it in the if isDone test, I.E.
Code:
  If isDone then
    'deal with the received sentence here
    'This code can be any length but ideally less than 20mS
    isDone=0
  Endif
This is at the end of the code that moves the servos.
Note: the isDone=0 line will allow the ISR to get the next line so should be at the end of the parse code.

Mike.
 
Actually, put the parse code where indicated and the rest of the code (whatever that is), after the if isDone code,
I.E.
Code:
  If isDone then
    'deal with the received sentence here
    'This code can be any length but ideally less than 20mS
    isDone=0
  Endif
  'other code here.
Wend

Mike.
 
Also note, the If isDone code only gets executed once every 20mS but the code could be changed so it executes much more often.

Mike.
 
Actually, put the parse code where indicated and the rest of the code (whatever that is), after the if isDone code,
I.E.
Code:
  If isDone then
    'deal with the received sentence here
    'This code can be any length but ideally less than 20mS
    isDone=0
  Endif
  'other code here.
Wend

Mike.
Hi m,
'other code here.
Will compare the peripheral DATA from this PIC with the transmitted RC DATA from BASE then make a calculation, to controll the MOTORS/SERVOS.
Onwards and upwards.
C
 
Also note, the If isDone code only gets executed once every 20mS but the code could be changed so it executes much more often.

Mike.
Hi m,
I'm trying to keep up, but the GPS sentences arrive each 250ms and the SERVO use their time, so I presume there is enough time, but I don't know how I test for it, except perhaps the Analyser. This is a new speed for me to soak in.
C.
 
Hi M,
Looking at your CODE, before HIGH INTERRUPT, there are tabs and after 3x spaces = 1 tab.
So it appears that you're sending some spaces and some tabs.
C
 
I thought the GPS sentence arrived 5 times per second so every 200mS. A sentence (if a full sentence) will take 80mS (or less) to arrive, worst case 20mS will elapse before it's parsed, that gives 100mS to parse the sentence (or we can take longer and miss a sentence) - the servos will stop moving if it takes 100mS to parse but that's not a problem as the movement is only a demonstration.

Note, human reaction time is generally accepted to be 0.2S = 200mS so we're still doing stuff faster than any human can.

Mike.
 
Hi M,
Looking at your CODE, before HIGH INTERRUPT, there are tabs and after 3x spaces = 1 tab.
So it appears that you're sending some spaces and some tabs.
C
You're right, not sure why but attached is a space only version (I hope),

Mike.
Edit, all tabs should be two spaces.
 

Attachments

  • Servo+USART+Timeout.txt
    6.1 KB · Views: 253
I thought the GPS sentence arrived 5 times per second so every 200mS. A sentence (if a full sentence) will take 80mS (or less) to arrive, worst case 20mS will elapse before it's parsed, that gives 100mS to parse the sentence (or we can take longer and miss a sentence) - the servos will stop moving if it takes 100mS to parse but that's not a problem as the movement is only a demonstration.

Note, human reaction time is generally accepted to be 0.2S = 200mS so we're still doing stuff faster than any human can.

Mike.
Hi M,
Yes, they arrive 5/sec, let's hope it all fits in, I'm about to set up 'live' tests, but got to write some CODE to make it do something. (Not sure whatthat will look like?)

As for reaction time, the craft flying at 30MPH may be more relevant.
C
 
If you load the file into Notepad++ you can do a search and replace two spaces with a tab. I'll make sure in future all indenting is tabs only.

Mike.
 
Somehow, a line got added to a remark and so is missing,

Attached is the code with the line.

Mike.
 

Attachments

  • Servo+USART+Timeout.txt
    5.6 KB · Views: 248
Somehow, a line got added to a remark and so is missing,

Attached is the code with the line.

Mike.
Hi M,
I haven't got used to it yet, but in SIM, I can send an NMEA sentence see BUFF, and READ the first CHAR which is '$'
And my test LEDS are flashing too.
Not forgetting it's all TABBED.

Can you tell me what actually goes in
'adjust servo positions here
'deal with the received sentence here
'other code here.

Well done, thanks.
C
 

Attachments

  • #76.jpg
    #76.jpg
    548.5 KB · Views: 229
Last edited:
The code in the while 1 loop is just to move the servos back and forth to test the servo ISR code.
Once finished the servo exercising code won't be there and instead will be the parse code and the result of that parsing will set the servo positions.
In the 'deal with the received sentence here
will go the code to parse the sentence as we now have a full sentence.
In #59 you asked,
Where should I put the PARSE and rest of the CODE?
I don't know what "the rest of the code" is but it goes where the comment 'other code here. is.

The idea is that it'll wizz around in the while, wend loop doing nothing until something needs to happen, if isDone gets set then a complete sentence has been received and can be parsed and used to set the servo positions (and isDone set back to zero so the ISR will fetch the next sentence). If something else needs to happen then it needs a way to know it needs to happen - i'm guessing this is the "rest of the CODE" mentioned above.

Note, the while, wend loop is the same as your main: goto main loop just more accepted as good coding practice.

Mike.
 
The code in the while 1 loop is just to move the servos back and forth to test the servo ISR code.
Once finished the servo exercising code won't be there and instead will be the parse code and the result of that parsing will set the servo positions.
In the 'deal with the received sentence here
will go the code to parse the sentence as we now have a full sentence.
In #59 you asked,

I don't know what "the rest of the code" is but it goes where the comment 'other code here. is.

The idea is that it'll wizz around in the while, wend loop doing nothing until something needs to happen, if isDone gets set then a complete sentence has been received and can be parsed and used to set the servo positions (and isDone set back to zero so the ISR will fetch the next sentence). If something else needs to happen then it needs a way to know it needs to happen - i'm guessing this is the "rest of the CODE" mentioned above.

Note, the while, wend loop is the same as your main: goto main loop just more accepted as good coding practice.

Mike.
Hi M,
REMOTE=PIC4
In #44 and the GPS CODE under '-------- PARSE UTILITIES -------------------------
is the GPS PARSE section. This extracts the TIME, LAT, LON from the REMOTE GPS.

Regarding only the Location:
The "rest of the CODE" is the calculations etc, which will be pages of CODE. e,g, comparisons, and the amount of movement to make. (As mentioned, I haven't given it much thought, untill all of the peripherals are working)

'Live' the SERVO moves FOR/REV and I've played with the speed settings. I undertsand that the FOR/REV section will be replaced by actual MOVE numbers.
C
 

Latest threads

New Articles From Microcontroller Tips

Back
Top