1. 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.
    Dismiss Notice

GPS controlled NMEA DATA following tracker

Discussion in 'Oshonsoft' started by camerart, Dec 27, 2015.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi,

    Firstly, I have other threads on this subject open, but they could be confusing!! e,g, (http://www.electro-tech-online.com/threads/gps-data-tracker-for-antenna-aiming.140729/) So I hope that this one is clearer? I have attached a program, that has been written and helped by others on this and other forums, so thanks to them.

    What the program does is read an azimuth or AZIMVAL angle as a 3x digit number e,g, 090 = 90degrees. The tracker compares this with a base angle POSCNT set to '0' at north and counts round 360 degrees, so if AZIMVAL = 090 then the tracker moves round 90 counts till it points at 90degrees. There are a number of extra things to note, such as degrees are actually counted as a 4 digit number so 090 = 0900. also counts are QUADRATURE etc.

    The program has gone through many revisions. I have spent a long time testing PWM, velocity, slow and fast braking etc, but find the best results have been from the more simple: 'If AZIMVAL<POSCNT then go one way and visa versa. If AZIMVAL=POSCNT then stop'. This sometimes works and stops, but over-runs a few degrees, and sometimes oscillates within the SETPOINT or '1deg' either side. What is happening is, as the SETPOINT is passed the program re-sets AZIMVAL, so there can be no more comparisons before actually stopping.

    What I am hoping for is at SETPOINT set BRAKE and wait for a split second till stopped before updating AZIMVAL so it can keep comparing. Later if necessary, I can widen the each side of SETPOINT degrees till the BRAKE stops at or near SETPOINT. I think the fast oscillations with introduce a kind of PWM, but I'm not sure, so hopefully only '1' bounce will occur.

    The program is ok above the '////////////////////////////// line. (Check for errors)

    I hope it's all understandable and looking forward to any replies. (I will update this post if there are any errors.)

    EDIT: I've made some progress with the attached program. This now stops at the SET POINT. It will receive data at 1sec intervals, but perhaps errors if the data is too far to move before the next is received. It would be better if the incoming data was held ready for the next input instead of as it is now. Also the timer0 needs setting.

    Camerart.
     

    Attached Files:

    Last edited: Jan 2, 2016
  2. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    I have updated the program, which needs more work, but does stop at the set-point received. It stops abruptly at the set-point, which I'm sure could be corrected with PWM, as previous programs, but for me this is too difficult.

    One thing to note is that: The motor I'm using has magnetic poles that won't allow it to stop and stay in the same position. This means that if the same data is input repeatedly, the motor will keep trying to correct slightly. I will try widening the set-point from 1 deg to 'say' 3deg. Other motor may have different characteristics.

    Camerart.
     
  3. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    749
    Likes:
    75
    Location:
    Worcestershire UK
    Hi camerart , Top marks for your perseverance with your project ... the motor stopping thing will depend on the number of poles , if you could gear down the output you would get a 'finer' position .
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.

    Hi G,

    I made the tracker over a year ago, much work! There aren't many options but to persevere and get it working or skip it:arghh: (I'm sure I've bored people to death with it:rolleyes:)

    Regarding the motor poles: The motor has a 1:100 gearbox with an opto disk on the motor rotor. The motor has 10 steps and the opto disk has 36 steps, which don't always match.

    HAPPY NEW YEAR

    C.
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    The program attached in post #1 mostly stops at the SETPOINT, but sometimes doesn't stop at BRAKE as it passes '0' and bounces back from the reverse motor direction and then oscillates.
    I am now trying to widen the DEADBAND by '1' degree each side of SETPOINT where the BRAKE is applied. The BRAKE will be on over 3degrees.

    I have attached the latest program. It brakes if '0'OR'1' is entered it simulates and BRAKES then resets.

    I know there are errors, but my question is: Below the OUTSIDEDEADBAND: line. Is the way I've written lines such as (If poscnt - azimvaltemp - 20 >= 1800 Then) correct?

    Any other corrections welcomed.

    EDIT:Program in post#1 updated

    C.
     

    Attached Files:

    Last edited: Jan 2, 2016
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi,

    I've realised that there is a problem when subtracting a DEADBAND around the zero point of a 360degree circle. As Oshonsoft doesn't cater for negative numbers (Correct me if I'm wrong) if a DEADBAND is subtracted from a number that takes it negative, then it doesn't work. Is there a way round this please?

    C.
     
  8. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    257
    Likes:
    15
    Location:
    Helsinki, Finland
    If deadband > degrees you can subtract with 360+degrees-deadband
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    I mini-demo Basic program showing how to use Single variables for the Sign.
    E
     

    Attached Files:

  10. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    257
    Likes:
    15
    Location:
    Helsinki, Finland
    I think in the demo it should be:
    If a < 0 Then
    a = 360 + a
    The demo gives correct result only if x is exactly 0

    With integers ( unsigned ) it is also easy:
    If x < y Then
    a = 360-(y-x)
    Else a=x-y
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi E and J,

    I looked a the examples posted, thanks. Also noticing a difference of opinion.

    If you look at the image posted, you will see that 'A' is entered as a Degree then a calculation x it by 9.95 to make it match 'B' which is a count 0000 to 3581 being a 360 Degree circle. I'm concerned about crossing zero, when 'B' will flip from 3581 to 0000 or 0000 to 3581.

    I want to 'in this case' have a 20 count each side of the SETPOINT as a DEADBAND. Bear in mind that Oshonsoft doesn't like decimal points.

    How does this affect your answers, please?

    C.
     

    Attached Files:

    • A.gif
      A.gif
      File size:
      6.9 KB
      Views:
      131
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C
    Look at this, NOTE: the use of SINGLE variable!!!
    Define SINGLE_DECIMAL_PLACES = 2

    Code (text):

    Define CONFIG = 0x23e4
    Define CONFIG2 = 0x3eff

    '16F887
    AllDigital
    Define SIMULATION_WAITMS_VALUE = 1  '''''''''''''''''''
    Define SINGLE_DECIMAL_PLACES = 2

    Define CLOCK_FREQUENCY = 8
    Define SPICLOCK_STRETCH = 5
    Define I2CCLOCK_STRETCH = 10  ''20  ''50
    Define I2CREAD_DELAYUS = 100  '200  ''400

    Define LCD_INITMS = 2
    Define LCD_LINES = 4
    Define LCD_CHARS = 20
    Define LCD_BITS = 4
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 4
    Define LCD_EREG = PORTB
    Define LCD_EBIT = 3
    Define LCD_RSREG = PORTB
    Define LCD_RSBIT = 2
    Define LCD_RWREG = PORTB
    Define LCD_RWBIT = 1
    Define LCD_READ_BUSY_FLAG = 1

    ADCON0 = %01000011
    ADCON1 = %10001110
    ANSEL = %00000011
    OSCCON = %01110000

    TRISA = %000011111
    TRISB = %00000001
    TRISC = %11000011
    TRISD = %00001111
    TRISE = %00000111

    Dim x As Single
    Dim y As Single
    Dim a As Single

    x = 0  '000 degree
    y = 10.75  'band

    Lcdinit
    WaitMs 100
    Lcdcmdout LcdLine1Home
    Lcdout "x= ", #x, "    ", " y = ", #y

    main:

    a = x - y

    Lcdcmdout LcdLine2Home

    Lcdout "a= ", #a
    If a < 0 Then
    Lcdcmdout LcdLine3Home
    Lcdout "a is minus value"
    a = a + 360
    Lcdcmdout LcdLine4Home
    Lcdout "So, Drive ", #a, "deg"
    Endif

    Goto main

    End                                          
     
     

    Attached Files:

    • A04.gif
      A04.gif
      File size:
      6.1 KB
      Views:
      148
  13. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    Bear in mind that Oshonsoft doesn't like decimal points.

    Define SINGLE_DECIMAL_PLACES = 2 'in program.

    C.
     

    Attached Files:

    Last edited: Jan 12, 2016
  14. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    257
    Likes:
    15
    Location:
    Helsinki, Finland
    You have to use single variables for that.
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi J,

    That did the trick, thanks.

    C,
     
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Didn't you read thru my program listing??
    Dim x As Single
    Dim y As Single
    Dim a As Single


    E
    Also from Post #8
    I mini-demo Basic program showing how to use Single variables for the Sign
     
  17. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    I did scan it, and noticed that TRISA has 9bits, but missed the SINGLEs.

    What do these lines do? They're not for my puspose are they?
    Define SPICLOCK_STRETCH = 5
    Define I2CCLOCK_STRETCH = 10 ''20 ''50
    Define I2CREAD_DELAYUS = 100 '200 ''400

    Thanks, C.
     
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Those SPI/I2C lines are from a bigger program which I chopped down to create the demo, I should have deleted them.

    Interesting that the Compiler didn't pick up on that PORTA typo.?

    Do you now have sufficient info in order to solve the 'minus' and 'deci-points' problems.?
    E
     
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    I've probably got enough info, time will tell if I've got enough brain cells.

    C.
     
  20. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi,

    I have an = that uses dband, but the dband variable shows more that two decimal places, so is not exactly the same, which doesn't work. Any ideas please?

    C.
     

    Attached Files:

  21. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    257
    Likes:
    15
    Location:
    Helsinki, Finland
    The single type variable has 7 digit precision in calculations.
    Single_decimal_places = 2 means that only 2 decimals are displayed.
     
    Last edited: Jan 13, 2016

Share This Page