Shop OBEX P1 Docs P2 Docs Learn Events
Switching from Demo Board to Gadget Gangster — Parallax Forums

Switching from Demo Board to Gadget Gangster

GVSU_EGRGVSU_EGR Posts: 5
edited 2012-02-10 13:14 in General Discussion
I am working on a school project with other students. We originally had a circuit and code that fully worked on the Demo Board. We are now trying to get the same code and circuit to work on a Gadget Gangster board. We can not figure out why it is not working. Is there anything that needs to change on either circuit or the code to make this transition? We are in dire need of help! 1/4 of the semester is already gone!

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2012-02-10 09:07
    Can you post your code?

    Can you tell us which parts are not working?

    Are you using certain hardware on the Demo Board that may have different pin assignments on the GG board?

    The more details you provide, the better/faster, people can help!
  • GVSU_EGRGVSU_EGR Posts: 5
    edited 2012-02-10 09:18
    We are not getting serial communication with the GG board. We can however get a simple led to turn on and off with different simple code.

    Does the GG use a different baud rate?

    We are not using any hardware on the board other than the propeller chip and both boards have the same chip.

    At this time we can not narrow it down to what part is not working. Any help with general difference between the two boards would be good to know.

    Main code below:
    [COLOR=#000000][FONT=Arial]{{[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]
            This code takes in two numbers from an A/D converter.  From those numbers, a variable (Input) is assigned, and depending[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]        on the input, the lawn mower will perform a certain action (i.e. go forward, turn, reverse, etc.)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]}}[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]CON[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  _clkmode  = xtal1 + pll16x[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  _xinfreq  = 5_000_000[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]  US_005 = 80_000_000 / 1_000_000 * 5                           ' 5us[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]  PCM_interval = 16_700               ' PCM interval <-- This is not critical, this just happened[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' to be what the transmitter scoped at. The real requirement is that[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' this value is about 20mS to 30mS. Note: This is under 20 mS due to[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' the long calculation times for the code.  The total length measured[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' with and o-scope is 20 mS. [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  __buffer_size = 11                                  [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  PCM_OutputPin = 5                   ' Specify bit stream output pin[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  PinE = 6                            ' Pin connected to the Reset Button[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  Idle = 1250                         ' Idle Modulation for the different channels[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  CH1_F1 = Idle + 200                       ' Slow Forward [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH1_F2 = Idle + 400                       ' Fast Forward[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH1_R1 = Idle - 200                       ' Slow Reverse[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH1_R2 = Idle - 400                        ' Fast Reverse[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  CH4_F1 = Idle + 200                       ' Slow Forward[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH4_F2 = Idle + 400                       ' Fast Forward[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH4_R1 = Idle - 200                       ' Slow Reverse[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH4_R2 = Idle - 400                        ' Fast Reverse[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]con[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  #0, CLS, HOME, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR           ' PST formmatting control[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]VAR[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  Long CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH3[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH4[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH5[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH6[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long CH4_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long Dly[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long SyncPoint[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long Input    [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long Stack1 [25]          'Use a different stack for each cog[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long Stack2 [25][/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long State[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  long analog1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long analog0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  ''Long Input[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long ana1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long ana0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long ana1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Long ana0_old [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  byte ch  [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  byte ch_count  [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  byte buffer[__buffer_size] [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  byte buffer_cnt[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]OBJ[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] '' SERIAL: "FullDuplexSerial"[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  PPM : "PCM_OUT"                'Changes the Channels' duration in a continuous PPM signal[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  adc : "jm_adc0834_ez"          'A/D converter code[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  pst : "fullduplexserial"       'Used for printing to the terminal                                [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]pub Main [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] adc.init(0, 1, 2)                                             ' setup ADC[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] pst.start(31, 30, 00, 115_200)                             ' start terminal[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] pst.tx(CLS)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] pst.str(string("Sip-and-Puff Lawn Mower Code: Below is the data from the A/D Chip and the Resulting Input, State and Channel Status."))[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] PPM.start(PCM_OutputPin)                                       'Initialize PPM signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] State := 0        'Start the mower in it's idle state with no input[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Input := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] CH1 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] CH4 := Idle[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] PPM.CC(CH1, CH4)      'Update the PPM signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] cognew(Get_Inputs, @stack1)         'Continuously takes in numbers for the A/D converter and assigns a number to the Input[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] cognew(Controls, @stack2)           'Continuously calls PPM.CC to update the PPM signal according to the Input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] loop        'Goes to the printing loop for trouble shooting[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]pub loop   [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  repeat[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(HOME)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(LF)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(LF)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    ''repeat ch from 0 to 3[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      ''pst.dec(ch)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.str(string(": "))[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      analog0 := adc.read(0)                                    ' read raw, 0-255[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      analog1 := adc.read(1)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)   [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.dec(analog0)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.dec(analog1)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      analog0 := adc.scale(analog0, 750, 2250)                    ' scale to 750-2250 [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      analog1 := adc.scale(analog1, 750, 2250) [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.dec(analog0)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.dec(analog1)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CR)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(CLRDN)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]    pst.str(string("Input =  "))[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.dec(Input)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CR)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(CLRDN)                                             ' terminal clean-up[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]    pst.str(string("State =  "))[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.dec(State)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CR)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(CLRDN)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]      pst.str(string("CH1 =  "))[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.dec(CH1)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CR)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(CLRDN)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]      pst.str(string("CH4 =  "))[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.dec(CH4)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(TAB)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CLREOL)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]      pst.tx(CR)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    pst.tx(CLRDN)  [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    waitcnt(clkfreq / 10 + cnt)[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]Pub Get_Inputs[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]repeat[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  ana1 := analog1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  ana0 := analog0[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     if ((ana1 > 1500) AND (ana1_old < 1500))           '' Threshold number for a hard puff[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          Input := 1[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     elseif ((ana1 > 1000) AND (ana1 < 1500))           '' Number range for a soft puff[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          Input := 4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     elseif ((ana0 > 1700) AND (ana0_old < 1700))       '' Threshold number for a hard sip[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          Input := 2[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     elseif ((ana0 > 1000) AND (ana0 < 1700))           '' Threshold number for a soft sip[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          Input := 3[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     else[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                                        '' Input is set to zero if the tube experiences no significant pressure[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          Input := 0  [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  ana1_old := ana1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  ana0_old := ana0[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  waitcnt(clkfreq / 10 + cnt) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]Pub Controls [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]repeat[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]   repeat while (ina[PinE] <> 0)  ''Continues that command loop as long as the emergency stop is not called[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     if (State == 0)           ''Command Code for when the mower is idle[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       if (Input == 0)         '' No input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := State         '' States and channels remain the same[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4)       '' Change PPM Signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 1)      '' Forward input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 1              '' Update state[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1_F1             '' Set the motors to forward slow speed[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4_F1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 2)      '' Reverse input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1_R1              '' Set the motors to reverse slow speed[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4_R1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 3)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 3)  ''Right input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_F1           '' Slow zero turn[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_R1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 0               '' Reset state and channels to idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)   [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 4)  '' Left input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_R1              ''slow zero turn[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_F1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 0                '' Reset States and channels to idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     elseif (State == 1)           ''Command Code for when the mower is moving forward[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       if (Input == 0)        ''No input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := State[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 1)   ''Forward input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1 + 200              '' Increase motor speed[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4 + 200[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          if (CH1 > CH1_F2)               '' Set limits to make sure that the motors can only turn at full speed[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_F2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          if (CH4 > CH4_F2)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_F2[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 2)     '' Reverse input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1 - 200[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4 - 200[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          if (CH1 == Idle)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            State := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          else[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            State := 1  [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 3)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          CH1_old := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4_old := CH4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 3)      ''Left input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_F2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_F1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := CH1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := CH4_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)   [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          CH1_old := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4_old := CH4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 4)         ''Right input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH4_F1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_F2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := CH1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := CH4_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)   [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     elseif (State == 2)           ''Command Code for when the mower is moving in reverse[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       if (Input == 0)        ''No input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := State[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 1)   ''Forward input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1 + 200              '' Increase motor speed[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4 + 200[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          if (CH1 := Idle)               '' Set to idle state is the motors are increased form reverse to idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            State := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          else [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            State := 2[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif  (Input == 2)     '' Reverse input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          State := 2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH1 := CH1 - 200[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4 := CH4 - 200[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          if (CH1 < CH1_R2)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_R2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          if (CH4 < CH4_R2)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_R2[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          PPM.CC(CH1, CH4) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 3)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          CH1_old := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4_old := CH4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 3)      ''Right input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_R1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_R2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := CH1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := CH4_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)   [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       elseif (Input == 4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]          CH1_old := CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          CH4_old := CH4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         repeat while (Input == 4)         ''Left input[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]            CH1 := CH1_R2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            CH4 := CH4_R1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]         State := 2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH1 := CH1_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         CH4 := CH4_old[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     else                                 '' Just in case an input is recieved out of range turn off motors and reset the states and inputs[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]       State := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       CH1 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       CH4 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       PPM.CC(CH1, CH4)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     waitcnt(clkfreq / 10 + cnt) [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] State := 0                             ''When the Emergency pin is high the repeat loop will end and the motors will be turned off and the state and input will be reset[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Input := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] CH1 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] CH4 := Idle[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] PPM.CC(CH1, CH4)
    
    [/FONT][/COLOR]
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-10 09:26
    Which pins are you using for serial communication?

    Do you only have one GG board? (To check if the problem is the difference between boards vs a bad chip.)

    Does the program used to turn the LED on and off use a PLL clock mode?

    It's relatively easy to damage the PLL circuit of the chip. When this happens the Propeller will work using the internal oscillator but not with a crystal.
  • GVSU_EGRGVSU_EGR Posts: 5
    edited 2012-02-10 09:29
    We are using pins 30 and 31 for serial communication.

    We have tried this on two different GG boards.

    No we do not use a PLL clock mode for the testing of the LED light

    The board is brand new and we stopped using the first one because we thought we may have done something to it.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-10 09:31
    Now, that I can see your code, I wonder if the GG SD card reader is interfering with your ADC. IIRC the USB GG board has the SD card reader on the lowest pins.

    Can you move the ADC circuit to different pins?
  • GVSU_EGRGVSU_EGR Posts: 5
    edited 2012-02-10 09:36
    For debugging everything except the first three lines of PST are commented out at the moment because we are first trying to achieve serial communication.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-02-10 09:41
    IIUC, the issue revolves around "fullduplexserial" object.

    I've used fullduplexserial many times over here and all I use are GG boards now..

    Any chance you could Archive your objects for us and attach them to the forum?

    OBC
  • GVSU_EGRGVSU_EGR Posts: 5
    edited 2012-02-10 09:47
    [COLOR=#000000][FONT=Arial]{{ pcm_out.spin }}[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]CON[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  PCM_interval = 16_700               ' 23.25uS PCM interval <-- This is not critical, this just happened[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' to be what my transmitter scoped at. The real requirement is that[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                                      ' this value is about 20uS to 30uS.[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]VAR[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] long Stack[16] [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] long duration  [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] long pin[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH2[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH3[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH4[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH5[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Word CH6[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Long Dly[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] Long SyncPoint[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]OBJ[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  RCTX : "PCM"       ''Actual Function that generates the PPM Signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]PUB Start(__pin)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  CH1 := 1100                           '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH2 := 800                            '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH3 := 800                            '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH4 := 1100                           '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH5 := 800                            '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CH6 := 800                            '700uS to 1500uS        1100uS = Center Position[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  ''Note: Channels 2, 3, 5, and 6 are never used and are not even connected in the reciever, so their[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  ''value is insignificant [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] pin := __pin          '' Pin for the PPM Output Signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] cognew(Loop1, @stack)    ''Begins the loop that continuously updates [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]PUB CC(C1, C4)    '' Called in main to update the PPM Signal[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial] CH1 := C1[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] CH4 := C4[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]PUB Loop1[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     repeat[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            Dly := ((clkfreq / 1_000_000) * PCM_interval)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            RCTX.PCM(Pin, CH1,CH2,CH3,CH4,CH5,CH6)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            'there is room here for a small amount of additional code [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]            waitcnt(((((clkfreq / 1_000_000) * PCM_interval)-(clkfreq / 1_000_000)*(300*7+CH1+CH2+CH3+CH4+CH5+CH6))) + cnt) [/FONT][/COLOR]
    


    [COLOR=#000000][FONT=Arial]{{[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]*******************************************************************[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]* Hitec "S" 72MHz PCM 6-Channel ULTRA Narrow Band RC transmitter  *[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]*******************************************************************[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]This object generates a pattern on the designated Pin as if it[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]were originating from the transmitter based on the channel values.[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]}}[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]VAR[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    Long Stack[16][/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    Long Dly[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    Long SyncPoint[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    Long microS[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]PUB Ping( uS , Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Dly := ((clkfreq / 1_000_000)* uS)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  SyncPoint := cnt[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  outa[Pin] := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  waitcnt(SyncPoint += Dly)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  outa[Pin] := 1[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]PUB Delay( uS )[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  Dly := ((clkfreq / 1_000_000)* uS)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  SyncPoint := cnt[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  waitcnt(SyncPoint += Dly)[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]PUB PCM(Pin, CH1, CH2, CH3, CH4, CH5, CH6)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     dira[Pin]~~[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin) [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH1)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH2)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH3)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH4)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH5)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Delay(CH6)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]     Ping(300,Pin)[/FONT][/COLOR]
    


    [COLOR=#000000][FONT=Arial]'' =================================================================================================[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   File....... jm_adc0834_ez.spin[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Purpose.... [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Author..... Jon McPhalen[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''               Copyright (c) 2009 Jon McPhalen[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''               -- see below for terms of use[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   E-mail..... jon@jonmcphalen.com[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Started.... [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Updated.... 01 JUL 2009[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Version 1.0 : original code[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Version 1.1 : code clean-up, added scale method[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''   Version 1.2 : renamed start (to init) and stop (to cleanup) to prevent I2C confusion[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]''[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]'' =================================================================================================[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]{{ [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                               5v[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                ADC0834        &#61463;[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]          &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;  &#9474;[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]         &#9472;&#9508;1 V+       VCC 14&#9500;&#9472;&#9472;&#9515;                [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  cs &#9472;&#61627;&#9472;&#9472;&#9472;&#9508;2 /CS       DI 13&#9500;&#9472;&#9472;&#9474;&#9472;&#9488;            [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] ch0 &#9472;&#61627;&#9472;&#9472;&#9472;&#9508;3 CH0      CLK 12&#9500;&#9472;&#9472;&#9474;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#61626;&#9472; clk   [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] ch1 &#9472;&#61627;&#9472;&#9472;&#9472;&#9508;4 CH1     SARS 11&#9500;&#9472; &#9474; &#9474;[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] ch2 &#9472;&#61627;&#9472;&#9472;&#9472;&#9508;5 CH2       DO 10&#9500;&#9472;&#9472;&#9474;&#9472;&#9531;&#9472;&#61629;&#61630;&#9472;&#9472;&#61626;&#61627; dio  [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial] ch3 &#9472;&#61627;&#9472;&#9472;&#9472;&#9508;6 CH3     VREF  9&#9500;&#9472;&#9472;&#9496;   10K[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       &#9484;&#9472;&#9472;&#9508;7 DGND    AGND  8&#9500;&#9472;&#9472;&#9488;                [/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       &#9474;  &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;  &#9474;[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]       &#61464;                       &#61464;                [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]}} [/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]con[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  US_005 = 80_000_000 / 1_000_000 * 5                           ' 5us                        ' [/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]var[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  long  cs[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  long  clk[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  long  dio[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]pub init(cspin, clkpin, diopin)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]'' Get pin assignments and set /CS and CLK pins to outputs[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]'' -- /CS initialized high to disable ADC0834[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  cs := cspin[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  outa[cs] := 1                                                 ' output high[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  dira[cs] := 1[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  clk := clkpin[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  outa[clk] := 0                                                ' output low[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  dira[clk] := 1[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  dio := diopin[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]pub cleanup[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]'' Makes IO pins inputs[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  dira[cs] := 0                                                 ' make inputs[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  dira[clk] := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  dira[dio] := 0     [/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]pub read(mode) | mux, level[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]'' Read ADC0834 channel[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]'' -- mode bits 1..0 specify channel (3..0)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]'' -- mode bit 2 specifies single-ended (0) or differential (1)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  mux := muxbits[(mode & 1)]                                 ' get mux bits[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  outa[cs] := 0                                                 ' activate adc[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  dira[dio] := 1                                                ' dio is output[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  waitcnt(US_005 + cnt)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  ' output mux bits, MSBFIRST[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  mux <<= (32-4)                                                ' prep for msb output[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  repeat 4                                                      ' send mux bits[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    outa[dio] := (mux <-= 1) & 1                                ' output a bit[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    outa[clk] := 1                                              ' clock the bit[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    waitcnt(US_005 + cnt)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    outa[clk] := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    waitcnt(US_005 + cnt)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  ' input data bits, MSBPOST[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  dira[dio] := 0                                                ' dio is input[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  level := 0                                                    ' clear work var[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  repeat 8[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    outa[clk] := 1                                              ' clock a bit[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    waitcnt(US_005 + cnt)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    outa[clk] := 0[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    waitcnt(US_005 + cnt)[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    level := (level << 1) | ina[dio]                            ' input data bit[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  outa[cs] := 1                                                 ' de-activate adc[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  return (level & $FF)[/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]pub scale(raw, minOut, maxOut)[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]'' Scales raw (0 to 255) value to new range: minOut to maxOut[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  if (raw < 256) and (minOut < maxOut)                          ' force legal values[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    return ((raw * (maxOut - minOut)) / 255) + minOut[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  else[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]    return raw  [/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]dat[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]muxbits         byte    00, 10, 01, 11              ' single ended[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]                byte    00, 10, 01, 11              ' differential   [/FONT][/COLOR]
    
    
    [COLOR=#000000][FONT=Arial]dat[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]{{[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  Copyright (c) 2009 Jon McPhalen[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  Permission is hereby granted, free of charge, to any person obtaining a copy of this[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  software and associated documentation files (the "Software"), to deal in the Software[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  without restriction, including without limitation the rights to use, copy, modify,[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  permit persons to whom the Software is furnished to do so, subject to the following[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  conditions:[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  The above copyright notice and this permission notice shall be included in all copies[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  or substantial portions of the Software.[/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE[/FONT][/COLOR]
    [COLOR=#000000][FONT=Arial]  OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Arial]}}                     [/FONT][/COLOR]
    
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-02-10 12:22
    Any chance we could get you to do an "archive without the Propeller tool" from the file menu of the Propeller Tool and attach it to this forum?

    OBC
  • max72max72 Posts: 1,155
    edited 2012-02-10 13:14
    Just guessing... Did you check if the parallax serial terminal port is correctly set?
    - under prop tool press F7 -> recognize the prop and the port
    - set the port accordingly in the teminal windows

    Massimo
Sign In or Register to comment.