View Full Version : Unsolved Switching from Demo Board to Gadget Gangster
GVSU_EGR
02-10-2012, 03:58 PM
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!
mindrobots
02-10-2012, 04:07 PM
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_EGR
02-10-2012, 04:18 PM
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:
{{
This code takes in two numbers from an A/D converter. From those numbers, a variable (Input) is assigned, and depending
on the input, the lawn mower will perform a certain action (i.e. go forward, turn, reverse, etc.)
}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
US_005 = 80_000_000 / 1_000_000 * 5 ' 5us
PCM_interval = 16_700 ' PCM interval <-- This is not critical, this just happened
' to be what the transmitter scoped at. The real requirement is that
' this value is about 20mS to 30mS. Note: This is under 20 mS due to
' the long calculation times for the code. The total length measured
' with and o-scope is 20 mS.
__buffer_size = 11
PCM_OutputPin = 5 ' Specify bit stream output pin
PinE = 6 ' Pin connected to the Reset Button
Idle = 1250 ' Idle Modulation for the different channels
CH1_F1 = Idle + 200 ' Slow Forward
CH1_F2 = Idle + 400 ' Fast Forward
CH1_R1 = Idle - 200 ' Slow Reverse
CH1_R2 = Idle - 400 ' Fast Reverse
CH4_F1 = Idle + 200 ' Slow Forward
CH4_F2 = Idle + 400 ' Fast Forward
CH4_R1 = Idle - 200 ' Slow Reverse
CH4_R2 = Idle - 400 ' Fast Reverse
con
#0, CLS, HOME, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR ' PST formmatting control
VAR
Long CH1
Long CH2
Long CH3
Long CH4
Long CH5
Long CH6
Long CH1_old
Long CH4_old
Long Dly
Long SyncPoint
Long Input
Long Stack1 [25] 'Use a different stack for each cog
Long Stack2 [25]
Long State
long analog1
Long analog0
''Long Input
Long ana1
Long ana0
Long ana1_old
Long ana0_old
byte ch
byte ch_count
byte buffer[__buffer_size]
byte buffer_cnt
OBJ
'' SERIAL: "FullDuplexSerial"
PPM : "PCM_OUT" 'Changes the Channels' duration in a continuous PPM signal
adc : "jm_adc0834_ez" 'A/D converter code
pst : "fullduplexserial" 'Used for printing to the terminal
pub Main
adc.init(0, 1, 2) ' setup ADC
pst.start(31, 30, 00, 115_200) ' start terminal
pst.tx(CLS)
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."))
PPM.start(PCM_OutputPin) 'Initialize PPM signal
State := 0 'Start the mower in it's idle state with no input
Input := 0
CH1 := Idle
CH4 := Idle
PPM.CC(CH1, CH4) 'Update the PPM signal
cognew(Get_Inputs, @stack1) 'Continuously takes in numbers for the A/D converter and assigns a number to the Input
cognew(Controls, @stack2) 'Continuously calls PPM.CC to update the PPM signal according to the Input
loop 'Goes to the printing loop for trouble shooting
pub loop
repeat
pst.tx(HOME)
pst.tx(LF)
pst.tx(LF)
''repeat ch from 0 to 3
''pst.dec(ch)
pst.str(string(": "))
analog0 := adc.read(0) ' read raw, 0-255
analog1 := adc.read(1)
pst.tx(CLREOL)
pst.tx(TAB)
pst.dec(analog0)
pst.tx(CLREOL)
pst.tx(TAB)
pst.dec(analog1)
pst.tx(CLREOL)
pst.tx(TAB)
analog0 := adc.scale(analog0, 750, 2250) ' scale to 750-2250
analog1 := adc.scale(analog1, 750, 2250)
pst.dec(analog0)
pst.tx(CLREOL)
pst.tx(TAB)
pst.dec(analog1)
pst.tx(CLREOL)
pst.tx(TAB)
pst.tx(CLREOL)
pst.tx(CR)
pst.tx(CLRDN)
pst.str(string("Input = "))
pst.dec(Input)
pst.tx(CLREOL)
pst.tx(TAB)
pst.tx(CLREOL)
pst.tx(CR)
pst.tx(CLRDN) ' terminal clean-up
pst.str(string("State = "))
pst.dec(State)
pst.tx(CLREOL)
pst.tx(TAB)
pst.tx(CLREOL)
pst.tx(CR)
pst.tx(CLRDN)
pst.str(string("CH1 = "))
pst.dec(CH1)
pst.tx(CLREOL)
pst.tx(TAB)
pst.tx(CLREOL)
pst.tx(CR)
pst.tx(CLRDN)
pst.str(string("CH4 = "))
pst.dec(CH4)
pst.tx(CLREOL)
pst.tx(TAB)
pst.tx(CLREOL)
pst.tx(CR)
pst.tx(CLRDN)
waitcnt(clkfreq / 10 + cnt)
Pub Get_Inputs
repeat
ana1 := analog1
ana0 := analog0
if ((ana1 > 1500) AND (ana1_old < 1500)) '' Threshold number for a hard puff
Input := 1
elseif ((ana1 > 1000) AND (ana1 < 1500)) '' Number range for a soft puff
Input := 4
elseif ((ana0 > 1700) AND (ana0_old < 1700)) '' Threshold number for a hard sip
Input := 2
elseif ((ana0 > 1000) AND (ana0 < 1700)) '' Threshold number for a soft sip
Input := 3
else
'' Input is set to zero if the tube experiences no significant pressure
Input := 0
ana1_old := ana1
ana0_old := ana0
waitcnt(clkfreq / 10 + cnt)
Pub Controls
repeat
repeat while (ina[PinE] <> 0) ''Continues that command loop as long as the emergency stop is not called
if (State == 0) ''Command Code for when the mower is idle
if (Input == 0) '' No input
State := State '' States and channels remain the same
CH1 := CH1
CH4 := CH4
PPM.CC(CH1, CH4) '' Change PPM Signal
elseif (Input == 1) '' Forward input
State := 1 '' Update state
CH1 := CH1_F1 '' Set the motors to forward slow speed
CH4 := CH4_F1
PPM.CC(CH1, CH4)
elseif (Input == 2) '' Reverse input
State := 2
CH1 := CH1_R1 '' Set the motors to reverse slow speed
CH4 := CH4_R1
PPM.CC(CH1, CH4)
elseif (Input == 3)
repeat while (Input == 3) ''Right input
CH1 := CH1_F1 '' Slow zero turn
CH4 := CH4_R1
PPM.CC(CH1, CH4)
State := 0 '' Reset state and channels to idle
CH1 := Idle
CH4 := Idle
PPM.CC(CH1, CH4)
elseif (Input == 4)
repeat while (Input == 4) '' Left input
CH1 := CH1_R1 ''slow zero turn
CH4 := CH4_F1
PPM.CC(CH1, CH4)
State := 0 '' Reset States and channels to idle
CH1 := Idle
CH4 := Idle
PPM.CC(CH1, CH4)
elseif (State == 1) ''Command Code for when the mower is moving forward
if (Input == 0) ''No input
State := State
CH1 := CH1
CH4 := CH4
PPM.CC(CH1, CH4)
elseif (Input == 1) ''Forward input
State := 1
CH1 := CH1 + 200 '' Increase motor speed
CH4 := CH4 + 200
if (CH1 > CH1_F2) '' Set limits to make sure that the motors can only turn at full speed
CH1 := CH1_F2
if (CH4 > CH4_F2)
CH4 := CH4_F2
PPM.CC(CH1, CH4)
elseif (Input == 2) '' Reverse input
State := 2
CH1 := CH1 - 200
CH4 := CH4 - 200
if (CH1 == Idle)
State := 0
else
State := 1
PPM.CC(CH1, CH4)
elseif (Input == 3)
CH1_old := CH1
CH4_old := CH4
repeat while (Input == 3) ''Left input
CH1 := CH1_F2
CH4 := CH4_F1
PPM.CC(CH1, CH4)
State := 1
CH1 := CH1_old
CH4 := CH4_old
PPM.CC(CH1, CH4)
elseif (Input == 4)
CH1_old := CH1
CH4_old := CH4
repeat while (Input == 4) ''Right input
CH1 := CH4_F1
CH4 := CH4_F2
PPM.CC(CH1, CH4)
State := 1
CH1 := CH1_old
CH4 := CH4_old
PPM.CC(CH1, CH4)
elseif (State == 2) ''Command Code for when the mower is moving in reverse
if (Input == 0) ''No input
State := State
CH1 := CH1
CH4 := CH4
PPM.CC(CH1, CH4)
elseif (Input == 1) ''Forward input
State := 1
CH1 := CH1 + 200 '' Increase motor speed
CH4 := CH4 + 200
if (CH1 := Idle) '' Set to idle state is the motors are increased form reverse to idle
State := 0
else
State := 2
PPM.CC(CH1, CH4)
elseif (Input == 2) '' Reverse input
State := 2
CH1 := CH1 - 200
CH4 := CH4 - 200
if (CH1 < CH1_R2)
CH1 := CH1_R2
if (CH4 < CH4_R2)
CH4 := CH4_R2
PPM.CC(CH1, CH4)
elseif (Input == 3)
CH1_old := CH1
CH4_old := CH4
repeat while (Input == 3) ''Right input
CH1 := CH1_R1
CH4 := CH4_R2
PPM.CC(CH1, CH4)
State := 2
CH1 := CH1_old
CH4 := CH4_old
PPM.CC(CH1, CH4)
elseif (Input == 4)
CH1_old := CH1
CH4_old := CH4
repeat while (Input == 4) ''Left input
CH1 := CH1_R2
CH4 := CH4_R1
PPM.CC(CH1, CH4)
State := 2
CH1 := CH1_old
CH4 := CH4_old
PPM.CC(CH1, CH4)
else '' Just in case an input is recieved out of range turn off motors and reset the states and inputs
State := 0
CH1 := Idle
CH4 := Idle
PPM.CC(CH1, CH4)
waitcnt(clkfreq / 10 + cnt)
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
Input := 0
CH1 := Idle
CH4 := Idle
PPM.CC(CH1, CH4)
Duane Degn
02-10-2012, 04:26 PM
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_EGR
02-10-2012, 04:29 PM
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 Degn
02-10-2012, 04:31 PM
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_EGR
02-10-2012, 04:36 PM
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)
02-10-2012, 04:41 PM
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_EGR
02-10-2012, 04:47 PM
{{ pcm_out.spin }}
CON
PCM_interval = 16_700 ' 23.25uS PCM interval <-- This is not critical, this just happened
' to be what my transmitter scoped at. The real requirement is that
' this value is about 20uS to 30uS.
VAR
long Stack[16]
long duration
long pin
Word CH1
Word CH2
Word CH3
Word CH4
Word CH5
Word CH6
Long Dly
Long SyncPoint
OBJ
RCTX : "PCM" ''Actual Function that generates the PPM Signal
PUB Start(__pin)
CH1 := 1100 '700uS to 1500uS 1100uS = Center Position
CH2 := 800 '700uS to 1500uS 1100uS = Center Position
CH3 := 800 '700uS to 1500uS 1100uS = Center Position
CH4 := 1100 '700uS to 1500uS 1100uS = Center Position
CH5 := 800 '700uS to 1500uS 1100uS = Center Position
CH6 := 800 '700uS to 1500uS 1100uS = Center Position
''Note: Channels 2, 3, 5, and 6 are never used and are not even connected in the reciever, so their
''value is insignificant
pin := __pin '' Pin for the PPM Output Signal
cognew(Loop1, @stack) ''Begins the loop that continuously updates
PUB CC(C1, C4) '' Called in main to update the PPM Signal
CH1 := C1
CH4 := C4
PUB Loop1
repeat
Dly := ((clkfreq / 1_000_000) * PCM_interval)
RCTX.PCM(Pin, CH1,CH2,CH3,CH4,CH5,CH6)
'there is room here for a small amount of additional code
waitcnt(((((clkfreq / 1_000_000) * PCM_interval)-(clkfreq / 1_000_000)*(300*7+CH1+CH2+CH3+CH4+CH5+CH6))) + cnt)
{{
************************************************** *****************
* Hitec "S" 72MHz PCM 6-Channel ULTRA Narrow Band RC transmitter *
************************************************** *****************
This object generates a pattern on the designated Pin as if it
were originating from the transmitter based on the channel values.
}}
VAR
Long Stack[16]
Long Dly
Long SyncPoint
Long microS
PUB Ping( uS , Pin)
Dly := ((clkfreq / 1_000_000)* uS)
SyncPoint := cnt
outa[Pin] := 0
waitcnt(SyncPoint += Dly)
outa[Pin] := 1
PUB Delay( uS )
Dly := ((clkfreq / 1_000_000)* uS)
SyncPoint := cnt
waitcnt(SyncPoint += Dly)
PUB PCM(Pin, CH1, CH2, CH3, CH4, CH5, CH6)
dira[Pin]~~
Ping(300,Pin)
Delay(CH1)
Ping(300,Pin)
Delay(CH2)
Ping(300,Pin)
Delay(CH3)
Ping(300,Pin)
Delay(CH4)
Ping(300,Pin)
Delay(CH5)
Ping(300,Pin)
Delay(CH6)
Ping(300,Pin)
'' ================================================== ===============================================
''
'' File....... jm_adc0834_ez.spin
'' Purpose....
'' Author..... Jon McPhalen
'' Copyright (c) 2009 Jon McPhalen
'' -- see below for terms of use
'' E-mail..... jon@jonmcphalen.com
'' Started....
'' Updated.... 01 JUL 2009
''
'' Version 1.0 : original code
'' Version 1.1 : code clean-up, added scale method
'' Version 1.2 : renamed start (to init) and stop (to cleanup) to prevent I2C confusion
''
'' ================================================== ===============================================
{{
5v
ADC0834
┌─────────────────┐ │
─┤1 V+ VCC 14├──┫
cs ────┤2 /CS DI 13├──│─┐
ch0 ────┤3 CH0 CLK 12├──│─┼────── clk
ch1 ────┤4 CH1 SARS 11├─ │ │
ch2 ────┤5 CH2 DO 10├──│─┻─── dio
ch3 ────┤6 CH3 VREF 9├──┘ 10K
┌──┤7 DGND AGND 8├──┐
│ └─────────────────┘ │
}}
con
US_005 = 80_000_000 / 1_000_000 * 5 ' 5us '
var
long cs
long clk
long dio
pub init(cspin, clkpin, diopin)
'' Get pin assignments and set /CS and CLK pins to outputs
'' -- /CS initialized high to disable ADC0834
cs := cspin
outa[cs] := 1 ' output high
dira[cs] := 1
clk := clkpin
outa[clk] := 0 ' output low
dira[clk] := 1
dio := diopin
pub cleanup
'' Makes IO pins inputs
dira[cs] := 0 ' make inputs
dira[clk] := 0
dira[dio] := 0
pub read(mode) | mux, level
'' Read ADC0834 channel
'' -- mode bits 1..0 specify channel (3..0)
'' -- mode bit 2 specifies single-ended (0) or differential (1)
mux := muxbits[(mode & 1)] ' get mux bits
outa[cs] := 0 ' activate adc
dira[dio] := 1 ' dio is output
waitcnt(US_005 + cnt)
' output mux bits, MSBFIRST
mux <<= (32-4) ' prep for msb output
repeat 4 ' send mux bits
outa[dio] := (mux <-= 1) & 1 ' output a bit
outa[clk] := 1 ' clock the bit
waitcnt(US_005 + cnt)
outa[clk] := 0
waitcnt(US_005 + cnt)
' input data bits, MSBPOST
dira[dio] := 0 ' dio is input
level := 0 ' clear work var
repeat 8
outa[clk] := 1 ' clock a bit
waitcnt(US_005 + cnt)
outa[clk] := 0
waitcnt(US_005 + cnt)
level := (level << 1) | ina[dio] ' input data bit
outa[cs] := 1 ' de-activate adc
return (level & $FF)
pub scale(raw, minOut, maxOut)
'' Scales raw (0 to 255) value to new range: minOut to maxOut
if (raw < 256) and (minOut < maxOut) ' force legal values
return ((raw * (maxOut - minOut)) / 255) + minOut
else
return raw
dat
muxbits byte 00, 10, 01, 11 ' single ended
byte 00, 10, 01, 11 ' differential
dat
{{
Copyright (c) 2009 Jon McPhalen
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}
Oldbitcollector (Jeff)
02-10-2012, 07:22 PM
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
max72
02-10-2012, 08:14 PM
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