Remote control by location (PIC in Oshonsoft)

Discussion in 'Embedded Systems and Microcontrollers' started by camerart, May 17, 2018.

  1. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    Ah yes! Here's the FONT
    C.
     
  2. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    Look at this demo, 5 ADC ports, using the serial Hserout tool.
    The PIC view ADC values set for volts.
    The Hserout are decimal values.

    E
    AA1 12-Jul-18 08.28.gif
     
  3. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    Works a treat, thanks.
    Just wiring the PCB into the transmitter for a 'live' test.
    As radio control doesn't use '0' I'll move all of the POTs up one and get rid of the zero, I presume that's ok.
    C.
     
  4. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    '0' in the context of being a ASCII = '0' = 0x30 = 00110000 its a value.
    E
    AA1 12-Jul-18 10.33.gif
     
    Last edited: Jul 12, 2018
  5. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    While I can scan ASM, I can't understand it, but what I meant was like this:
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    main:
    Adcin 0, vpot1 'CH1
    Adcin 1, vpot2 'CH2
    Adcin 2, vpot3
    Adcin 3, vpot4
    Adcin 4, vpot5
    Adcin 5, vpot6

    Hserout "CH1=", #vpot1, " CH2=", #vpot2, " CH3=", #vpot3, " CH4=", #vpot4, " CH5=", #vpot5, " CH6=", #vpot6, CrLf

    Goto get_mess

    Goto main
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    This works, is it ok?
    -------------------------------------------------------------------------------------------------------------------

    As you can see I also tried adding Goto 'get_mess' This produced this error..
    >>>>Hardware Stack Underflow.<<<<
    C.
     
  6. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    Check your GOTO's and GOSUB's, you are not 'entering and exiting' those routines correctly. Goto get_mess

    If you are testing the Transmit routine, why are you calling Get Mess.?????
    Thats a RXD input routine.
    E
     
  7. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    I'll leave the get_mess till later.

    Is the first part of #25 ok?
    C.
     
  8. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    When your code makes a GOSUB call it Pushes the Return Address onto a Stack,[ where it is saved] so when it completes the GOSUB and RETURN's it Pops that Return address off the Stack and the program execution continues from that Address.

    If you use a GOTO command which ends in a RETURN, if the Stack is empty you get Hardware Stack Underflow, because a GOTO does not Push an Address onto the Stack.
    If there was an 'old' Address on the Stack, this incorrect Return address would cause a program crash.

    E
     
  9. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    I've made a note of your explanation, thanks.

    I've got 4x Channels working 'LIVE' I can switch on LEDs with the transmitter levers. Great!
    Next I'll try to transmit to a computer terminal (Termite or Teraterm)
    EDIT: I tried transmitting to a terminal, and it copies the channel readings ok, but then stops after a few seconds. Each time I switch the transmitter OFF/ON, it starts again then repeats the stop.

    Here's a photo, it may need tidying up a bit:D
    C.
     
    Last edited: Jul 12, 2018
  10. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    Have you added or edited that program I posted.?
    There is nothing in the code to cause a break.
    E
     
  11. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    C.
    Hi E,
    Yes, I'd added lines to check the transmitter levers(Pots), which spoiled the LOOP.
    Your program works ok as you sent it.

    I've corrected some errors, nothing major, but we can only use 4 Analog inputs, till I make new PCBS.

    Will you check the lines between '######################### please?

    Here's the last working program:
    C.
     
    Last edited: Jul 13, 2018
  12. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi,
    The only section with ############# is this bit.??
    E
    ######################################
    ADCON0 = %00000001 'BIT0 = 1A/D EN This Selects AN0 thru AN5 [ you have set for AN0]
    ADCON1 = %00001001 'AN0-AN5 SET TO ANALOG IN Correct
    ADCON2 = % 1 x 100 100 'Set for Right Justify, 8 Tad , Fosc/4
    '#############################################
     
  13. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    E,
    So I assume they should be;
    ADCON0 = %00001111 4x Till I make new 6x AN PCBs
    ADCON1 = %00001001 'AN0-AN5 SET TO ANALOG IN Correct
    ADCON2 = % 1 100 100 'Set for Right Justify, 8 Tad , Fosc/4 (Is this ok?)

    C.
     
  14. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    Not correct.
    ADCON0 = %00001111 4x Till I make new 6x AN PCBs

    E
    AA1 13-Jul-18 10.57.gif
     
  15. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    How about this?
    ADCON0 = %00000100 (Only 4x for now)
    and change to this:
    ADCON0 =%0000110 when I make new 6x PCBs
    C
     
  16. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    hi C,
    Look at the ADCON0 notes in the d/s.
    You must enter all 8 Bits 0's or 1's to set up the ADC ADCON0 Byte correctly, [ bits 5 thru 2 select the channels] but the other bits also need to be set as required.
    E
     
  17. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    I always check the D/S, but sometimes it's not clear.

    Ok, another try:
    ADCON0 =%00100?1 For 4CH
    ADCON0 =%00110?1 Fro 6CH
    I'm not sure about BIT1
    EDIT: I've just seen that ADCON1 should be set for 4CH, so ADCON1 = %00001011
    C.
     
    Last edited: Jul 13, 2018
  18. ericgibbs

    Moderator

    Jan 29, 2010
    6,179
    1,171
    Hi C,
    Consider the bits 5 thru 2 of ADCON0 select the required channel.
    You are programming for 6 channels, when you write the code below
    The Oshonsoft Basic sets the correct ADC channel, prior to read from that channel.
    This operation was shown in that demo program I posted, it read all the 6 channels OK.
    Leave the ADCON0 as I set it.
    E

    Adcin 0, vpot1 '
    Adcin 1, vpot2 'CH2
    Adcin 2, vpot3
    Adcin 3, vpot4
    Adcin 4, vpot5
    Adcin 5, vpot6
     
  19. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi E,
    In #31, I found some errors in the PCB, so I had to change to 4CH temporarily, till I make new PCBs, sorry for the confusion.
    C.
     
  20. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    865
    34
    Hi,
    Here's the latest program: (Only 4x analog Channels till new PCBS)

    In a LIVE test, with the Throttle set LOW and AILERON, ELEVATOR, and RUDDER set CENTRAL.
    Here's is a readout from a computer terminal.

    All outputs are between 1000 and 2000, which when converted to uS should be suitable to drive SERVOs.
    C.
     
Loading...