Shop OBEX P1 Docs P2 Docs Learn Events
BS2 and PAK8 help needed. — Parallax Forums

BS2 and PAK8 help needed.

ArchiverArchiver Posts: 46,084
edited 2001-04-11 15:27 in General Discussion
Hello all, especially Al

Could someone give me some advice please.

Im using:
A BS2 powered by a 9volt battery.
A PAK8 powered by a regulator and a couple of capacitors from the same
battery.
2 servos powered by 4 1.5v cells.
I have an led on pin0 to show that the code is looping.
All the earths are tied.

When I download my code (included below) to the stamp from the development
environment. Everything works.
If I turn off the power to the stamp and PAK8 then turn on again. The servos
will either turn randomly or not at all.
If I then reset the stamp by earthing the reset pin. everything works as I
expect.

Is there an issue with what order the stamp and the PAK device are powered
up ?
or am I missing something obvious ?

Any tips would be appreciated.

Heres my code. Its a slightly modified version of the example supplied with
the PAK8 <<<<

' Change these to suit your setup
datap con 15 ' Data pin (I/O)
datapin var in15
clk con 14 ' Clk pin (output)
led con 0 ' led pin

' Register names
DURLOW con %000
DURHIGH con %001
HIGHDUR con %010
LOWDUR con %011
PSCALE con %100
PSBASE con %101
N con %110
CTRL con %111
center0 con 150
center1 con 150

output clk
output datap
output led

fpx var word ' Integer used by
some routines
fpb var byte ' byte
' parameters for FCommand
chan var nib
register var nib

' my routine here

gosub freset ' always reset!
gosub FTotalReset ' hard reset


' disable channel 0 + 1
chan=0
register=6
fpx=1
gosub FCommand
chan=1
gosub FCommand

gosub ServoCenter


for chan=0 to 1
fpb=3
gosub FJam
next

pause 5000

gosub forwards

pause 5000

gosub backwards

here:
toggle led
pause 250
goto here
end

' Subroutines
' #################################
' Center servos
ServoCenter:

chan=0
register=1
fpx=center0 ' 150 x 10 = 1.5mS
gosub FCommand
chan=1
fpx=center1
gosub FCommand
register=2
fpx=2000 ' 2000 x 10 = 20mS
gosub FCommand
chan=0
goto FCommand ' let FCommand return

forwards:
chan=0
register=1
fpx=center0 + 10
gosub FCommand
chan=1
fpx=center0 - 10
gosub FCommand
return

backwards:
chan=0
register=1
fpx=center0 - 10
gosub FCommand
chan=1
fpx=center0 + 10
gosub FCommand
return


' Reset the Pak8 I/O
FReset:
LOW DATAP
LOW CLK
HIGH CLK
HIGH DATAP
LOW CLK
return

' 0 is 0, 1 is 1, 2 is hi-z, 3 is
normal
' note: 3 enables channel to run!
FJam:
fpb=chan + (fpb<<3)+%01000000
goto FSendByte

FCommand:
' inputs chan = channel, register
= register
fpb=(register<<3) + chan
gosub FSendByte
fpb=fpx.lowbyte
gosub FSendByte
fpb=fpx.highbyte
goto FSendByte


FReadReg:
fpb=(register<<3) + chan +
%10000000
gosub FSendByte
' fall into FReadWord


FReadWord:
Shiftin
datap,clk,MSBPRE,[noparse][[/noparse]fpx.lowbyte,fpx.h
ighbyte]
return

FTotalReset:
fpb=$FF
FSendByte:
Shiftout datap,clk,MSBFIRST,[noparse][[/noparse]fpb]
return

FReadByte:
shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpb]
return

FPrescale:
' set fpb to the prescale constant
fpb = fpb + $C0
goto FSendByte

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-04-11 14:32
    Hi Gordon,

    It sounds like you have a reset problem. The PAK-VIII needs a fairly fast
    rise on Vdd or it will brown out. Here are some things to think about:

    1) Noise. Use decoupling caps. Also, make sure no inputs are floating.

    2) Slow Vdd. Vdd must rise and stabilize within about 15mS or so. You can
    determine if this is the problem by connecting the reset pin to Vdd through
    a 10K resistor. If the chip doesn't work, leave the power on and briefly
    ground the reset pin by touching a clip lead to the "cold" end of the
    resistor. If the chip works, you have a reset problem. You can try
    connecting the reset pin to the Stamp's reset pin or using an RC reset
    circuit.

    3) Clock problems. A 50MHz clock requires low stray capacitance and short
    leads. In some cases, a 10K resistor across the resonator will help. In some
    cases, a small capacitor from one (or both) of the RES pins will help. It
    depends on your construction. Ideally, you shouldn't need either of those,
    but it can help neutralize circuit oddities you may have.

    The fact that it works OK after you reset means your code should be OK. The
    brute force fix would be to tie the Stamp's reset pin to the reset pin of
    the PAK. However, if Vdd rises quickly enough that shouldn't be a problem.

    Let me know if that helps!

    Al Williams
    AWC
    * NEW: PAK-IX floating point A/D: http://www.al-williams.com/awce/pak9.htm


    >
    Original Message
    > From: Endersby, Gordon [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=EShATIfJo_g3d9ijXL1Pb7rvdM8nB_Rj2QAfEqXEM3Eh-06yeUnUwtOqVYpNhg4wnUanPwA3VQikCZzio74DtLg]gordon.endersby@m...[/url
    > Sent: Wednesday, April 11, 2001 5:53 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] BS2 and PAK8 help needed.
    >
    >
    >
    > Hello all, especially Al
    >
    > Could someone give me some advice please.
    >
    > Im using:
    > A BS2 powered by a 9volt battery.
    > A PAK8 powered by a regulator and a couple of capacitors from the same
    > battery.
    > 2 servos powered by 4 1.5v cells.
    > I have an led on pin0 to show that the code is looping.
    > All the earths are tied.
    >
    > When I download my code (included below) to the stamp from the development
    > environment. Everything works.
    > If I turn off the power to the stamp and PAK8 then turn on again.
    > The servos
    > will either turn randomly or not at all.
    > If I then reset the stamp by earthing the reset pin. everything works as I
    > expect.
    >
    > Is there an issue with what order the stamp and the PAK device are powered
    > up ?
    > or am I missing something obvious ?
    >
    > Any tips would be appreciated.
    >
    > Heres my code. Its a slightly modified version of the example
    > supplied with
    > the PAK8 <<<<
    >
    > ' Change these to suit your setup
    > datap con 15 ' Data pin (I/O)
    > datapin var in15
    > clk con 14 ' Clk pin (output)
    > led con 0 ' led pin
    >
    > ' Register names
    > DURLOW con %000
    > DURHIGH con %001
    > HIGHDUR con %010
    > LOWDUR con %011
    > PSCALE con %100
    > PSBASE con %101
    > N con %110
    > CTRL con %111
    > center0 con 150
    > center1 con 150
    >
    > output clk
    > output datap
    > output led
    >
    > fpx var word ' Integer used by
    > some routines
    > fpb var byte ' byte
    > ' parameters for FCommand
    > chan var nib
    > register var nib
    >
    > ' my routine here
    >
    > gosub freset ' always reset!
    > gosub FTotalReset ' hard reset
    >
    >
    > ' disable channel 0 + 1
    > chan=0
    > register=6
    > fpx=1
    > gosub FCommand
    > chan=1
    > gosub FCommand
    >
    > gosub ServoCenter
    >
    >
    > for chan=0 to 1
    > fpb=3
    > gosub FJam
    > next
    >
    > pause 5000
    >
    > gosub forwards
    >
    > pause 5000
    >
    > gosub backwards
    >
    > here:
    > toggle led
    > pause 250
    > goto here
    > end
    >
    > ' Subroutines
    > ' #################################
    > ' Center servos
    > ServoCenter:
    >
    > chan=0
    > register=1
    > fpx=center0 ' 150 x 10 = 1.5mS
    > gosub FCommand
    > chan=1
    > fpx=center1
    > gosub FCommand
    > register=2
    > fpx=2000 ' 2000 x 10 = 20mS
    > gosub FCommand
    > chan=0
    > goto FCommand ' let FCommand return
    >
    > forwards:
    > chan=0
    > register=1
    > fpx=center0 + 10
    > gosub FCommand
    > chan=1
    > fpx=center0 - 10
    > gosub FCommand
    > return
    >
    > backwards:
    > chan=0
    > register=1
    > fpx=center0 - 10
    > gosub FCommand
    > chan=1
    > fpx=center0 + 10
    > gosub FCommand
    > return
    >
    >
    > ' Reset the Pak8 I/O
    > FReset:
    > LOW DATAP
    > LOW CLK
    > HIGH CLK
    > HIGH DATAP
    > LOW CLK
    > return
    >
    > ' 0 is 0, 1 is 1, 2 is hi-z, 3 is
    > normal
    > ' note: 3 enables channel to run!
    > FJam:
    > fpb=chan + (fpb<<3)+%01000000
    > goto FSendByte
    >
    > FCommand:
    > ' inputs chan = channel, register
    > = register
    > fpb=(register<<3) + chan
    > gosub FSendByte
    > fpb=fpx.lowbyte
    > gosub FSendByte
    > fpb=fpx.highbyte
    > goto FSendByte
    >
    >
    > FReadReg:
    > fpb=(register<<3) + chan +
    > %10000000
    > gosub FSendByte
    > ' fall into FReadWord
    >
    >
    > FReadWord:
    > Shiftin
    > datap,clk,MSBPRE,[noparse][[/noparse]fpx.lowbyte,fpx.h
    > ighbyte]
    > return
    >
    > FTotalReset:
    > fpb=$FF
    > FSendByte:
    > Shiftout datap,clk,MSBFIRST,[noparse][[/noparse]fpb]
    > return
    >
    > FReadByte:
    > shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpb]
    > return
    >
    > FPrescale:
    > ' set fpb to the prescale constant
    > fpb = fpb + $C0
    > goto FSendByte
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-11 14:50
    Thanks for the fast response Al.

    Im new to electronics so I need to ask a couple of extra questions about
    your reply.
    Im learning fast though, Apart from reliably reading resistor values.

    1, How do I work out the values for the capacitors and where do I put them ?
    Do they go from the +5v from the regulator to the earth before I connect the
    PAK to the +5v.
    I thought that having a seperate regulator, even though its sharing an
    earth,
    would isolate the electronics from the noise from the servos.

    2, I can follow this one.

    3, Ive got this on a prototyping board and the resonator is about 1cm from
    the PAK8.
    Is that too far? The prototyping board is one of those where you can press
    in the component leads.
    I beleive its called a euroboard.

    10k resistor across the resonator. Do you mean join the two outer pins of
    the resonator with a resistor ?

    Where do I connect the capacitor/s? From the outer pins to where ?

    Thanks again

    Gordon





    Original Message
    From: Al Williams [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Y_qH0ABAsIPguFjUfzVUAxmhcfrY3NNTfTBll2RjEWMyjM92XhLa6mn2Mfi7UacziW9WUunSt8JDpvrkkD0]alw@a...[/url
    Sent: 11 April 2001 14:32
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] BS2 and PAK8 help needed.


    Hi Gordon,

    It sounds like you have a reset problem. The PAK-VIII needs a fairly fast
    rise on Vdd or it will brown out. Here are some things to think about:

    1) Noise. Use decoupling caps. Also, make sure no inputs are floating.

    2) Slow Vdd. Vdd must rise and stabilize within about 15mS or so. You can
    determine if this is the problem by connecting the reset pin to Vdd through
    a 10K resistor. If the chip doesn't work, leave the power on and briefly
    ground the reset pin by touching a clip lead to the "cold" end of the
    resistor. If the chip works, you have a reset problem. You can try
    connecting the reset pin to the Stamp's reset pin or using an RC reset
    circuit.

    3) Clock problems. A 50MHz clock requires low stray capacitance and short
    leads. In some cases, a 10K resistor across the resonator will help. In some
    cases, a small capacitor from one (or both) of the RES pins will help. It
    depends on your construction. Ideally, you shouldn't need either of those,
    but it can help neutralize circuit oddities you may have.

    The fact that it works OK after you reset means your code should be OK. The
    brute force fix would be to tie the Stamp's reset pin to the reset pin of
    the PAK. However, if Vdd rises quickly enough that shouldn't be a problem.

    Let me know if that helps!

    Al Williams
    AWC
    * NEW: PAK-IX floating point A/D: http://www.al-williams.com/awce/pak9.htm


    >
    Original Message
    > From: Endersby, Gordon [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=WBzNeorK_4wFPybVUVSM6kCUvsSGKM4N8D2P3XS86PS_sQ_MEgdAgpVHh2xpgytKSgQ0YxjZCAJjF_6DcYHeCsbWig]gordon.endersby@m...[/url
    > Sent: Wednesday, April 11, 2001 5:53 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] BS2 and PAK8 help needed.
    >
    >
    >
    > Hello all, especially Al
    >
    > Could someone give me some advice please.
    >
    > Im using:
    > A BS2 powered by a 9volt battery.
    > A PAK8 powered by a regulator and a couple of capacitors from the same
    > battery.
    > 2 servos powered by 4 1.5v cells.
    > I have an led on pin0 to show that the code is looping.
    > All the earths are tied.
    >
    > When I download my code (included below) to the stamp from the development
    > environment. Everything works.
    > If I turn off the power to the stamp and PAK8 then turn on again.
    > The servos
    > will either turn randomly or not at all.
    > If I then reset the stamp by earthing the reset pin. everything works as I
    > expect.
    >
    > Is there an issue with what order the stamp and the PAK device are powered
    > up ?
    > or am I missing something obvious ?
    >
    > Any tips would be appreciated.
    >
    > Heres my code. Its a slightly modified version of the example
    > supplied with
    > the PAK8 <<<<
    >
    > ' Change these to suit your setup
    > datap con 15 ' Data pin (I/O)
    > datapin var in15
    > clk con 14 ' Clk pin (output)
    > led con 0 ' led pin
    >
    > ' Register names
    > DURLOW con %000
    > DURHIGH con %001
    > HIGHDUR con %010
    > LOWDUR con %011
    > PSCALE con %100
    > PSBASE con %101
    > N con %110
    > CTRL con %111
    > center0 con 150
    > center1 con 150
    >
    > output clk
    > output datap
    > output led
    >
    > fpx var word ' Integer used by
    > some routines
    > fpb var byte ' byte
    > ' parameters for FCommand
    > chan var nib
    > register var nib
    >
    > ' my routine here
    >
    > gosub freset ' always reset!
    > gosub FTotalReset ' hard reset
    >
    >
    > ' disable channel 0 + 1
    > chan=0
    > register=6
    > fpx=1
    > gosub FCommand
    > chan=1
    > gosub FCommand
    >
    > gosub ServoCenter
    >
    >
    > for chan=0 to 1
    > fpb=3
    > gosub FJam
    > next
    >
    > pause 5000
    >
    > gosub forwards
    >
    > pause 5000
    >
    > gosub backwards
    >
    > here:
    > toggle led
    > pause 250
    > goto here
    > end
    >
    > ' Subroutines
    > ' #################################
    > ' Center servos
    > ServoCenter:
    >
    > chan=0
    > register=1
    > fpx=center0 ' 150 x 10 = 1.5mS
    > gosub FCommand
    > chan=1
    > fpx=center1
    > gosub FCommand
    > register=2
    > fpx=2000 ' 2000 x 10 = 20mS
    > gosub FCommand
    > chan=0
    > goto FCommand ' let FCommand return
    >
    > forwards:
    > chan=0
    > register=1
    > fpx=center0 + 10
    > gosub FCommand
    > chan=1
    > fpx=center0 - 10
    > gosub FCommand
    > return
    >
    > backwards:
    > chan=0
    > register=1
    > fpx=center0 - 10
    > gosub FCommand
    > chan=1
    > fpx=center0 + 10
    > gosub FCommand
    > return
    >
    >
    > ' Reset the Pak8 I/O
    > FReset:
    > LOW DATAP
    > LOW CLK
    > HIGH CLK
    > HIGH DATAP
    > LOW CLK
    > return
    >
    > ' 0 is 0, 1 is 1, 2 is hi-z, 3 is
    > normal
    > ' note: 3 enables channel to run!
    > FJam:
    > fpb=chan + (fpb<<3)+%01000000
    > goto FSendByte
    >
    > FCommand:
    > ' inputs chan = channel, register
    > = register
    > fpb=(register<<3) + chan
    > gosub FSendByte
    > fpb=fpx.lowbyte
    > gosub FSendByte
    > fpb=fpx.highbyte
    > goto FSendByte
    >
    >
    > FReadReg:
    > fpb=(register<<3) + chan +
    > %10000000
    > gosub FSendByte
    > ' fall into FReadWord
    >
    >
    > FReadWord:
    > Shiftin
    > datap,clk,MSBPRE,[noparse][[/noparse]fpx.lowbyte,fpx.h
    > ighbyte]
    > return
    >
    > FTotalReset:
    > fpb=$FF
    > FSendByte:
    > Shiftout datap,clk,MSBFIRST,[noparse][[/noparse]fpb]
    > return
    >
    > FReadByte:
    > shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpb]
    > return
    >
    > FPrescale:
    > ' set fpb to the prescale constant
    > fpb = fpb + $C0
    > goto FSendByte
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >




    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-11 15:05
    Hi Gordon,

    > 1, How do I work out the values for the capacitors and where do I
    > put them ?
    > Do they go from the +5v from the regulator to the earth before I
    > connect the
    > PAK to the +5v.
    > I thought that having a separate regulator, even though its sharing an
    > earth,
    > would isolate the electronics from the noise from the servos.

    Decoupling capacitors should be very close to the chip they are protecting.
    In general, you want at least one per chip. A .1UF will decouple high
    frequency noise. A 1uF cap will decouple a lot of noise also. In some
    applications you'll use both. The prototyping boards will tend to impress
    the clock noise on every pin because the board has a lot of capacitance and
    at 50MHz, that clock will wind up throughout the board. So the regulator
    isn't really an issue.

    Think about it this way. If you were building on a "perfect" circuit board
    (which doesn't exist) each part would be isolated from every other. However
    with a protoboard, you are basically attaching a capacitor from each wire to
    every adjacent wire. At DC that doesn't matter. But as frequency rises those
    capacitors look more like resistors (1/(2*pi*F*C)). So you basically have
    little resistive shorts between your circuit elements.

    > 3, Ive got this on a prototyping board and the resonator is about 1cm from
    > the PAK8.
    > Is that too far? The prototyping board is one of those where you can press
    > in the component leads.
    > I beleive its called a euroboard.

    No that shouldn't be too far. Make sure the leads are not any longer than
    necessary. I have found some protoboards (the less expensive ones) won't
    work well at all no matter what even at 10 or 20MHz. But I regularly layout
    50MHz oscillators for PAKs on protoboards.


    >
    > 10k resistor across the resonator. Do you mean join the two outer pins of
    > the resonator with a resistor ?

    Yes, that is one thing you can try if the clock is not starting.

    >
    > Where do I connect the capacitor/s? From the outer pins to where ?

    The capacitors should be small in value (10-20pF) and would go from the
    clock pins to ground.
    Neither of these steps should be necessary and if you have a scope and can
    see that the clock is reliably starting then you don't need them at all.
    However, sometimes the protoboard's stray capacitance and other factors can
    keep the clock from starting and these steps _might_ help.

    Al Williams
    AWC
    * NEW: PAK-IX floating point A/D: http://www.al-williams.com/awce/pak9.htm
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-11 15:27
    Thanks Al

    Wife and kids allowing ill give it a try tonite.

    Gordon


    Original Message
    From: Al Williams [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Fq5ANg0uQGU6DOxlo_ieHMO35R2c9ZpIaRqEPzinolg2zE-lRs8HTtv7oQv2xz9vZ7vRCijQozbv130]alw@a...[/url
    Sent: 11 April 2001 15:06
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] BS2 and PAK8 help needed.


    Hi Gordon,

    > 1, How do I work out the values for the capacitors and where do I
    > put them ?
    > Do they go from the +5v from the regulator to the earth before I
    > connect the
    > PAK to the +5v.
    > I thought that having a separate regulator, even though its sharing an
    > earth,
    > would isolate the electronics from the noise from the servos.

    Decoupling capacitors should be very close to the chip they are protecting.
    In general, you want at least one per chip. A .1UF will decouple high
    frequency noise. A 1uF cap will decouple a lot of noise also. In some
    applications you'll use both. The prototyping boards will tend to impress
    the clock noise on every pin because the board has a lot of capacitance and
    at 50MHz, that clock will wind up throughout the board. So the regulator
    isn't really an issue.

    Think about it this way. If you were building on a "perfect" circuit board
    (which doesn't exist) each part would be isolated from every other. However
    with a protoboard, you are basically attaching a capacitor from each wire to
    every adjacent wire. At DC that doesn't matter. But as frequency rises those
    capacitors look more like resistors (1/(2*pi*F*C)). So you basically have
    little resistive shorts between your circuit elements.

    > 3, Ive got this on a prototyping board and the resonator is about 1cm from
    > the PAK8.
    > Is that too far? The prototyping board is one of those where you can press
    > in the component leads.
    > I beleive its called a euroboard.

    No that shouldn't be too far. Make sure the leads are not any longer than
    necessary. I have found some protoboards (the less expensive ones) won't
    work well at all no matter what even at 10 or 20MHz. But I regularly layout
    50MHz oscillators for PAKs on protoboards.


    >
    > 10k resistor across the resonator. Do you mean join the two outer pins of
    > the resonator with a resistor ?

    Yes, that is one thing you can try if the clock is not starting.

    >
    > Where do I connect the capacitor/s? From the outer pins to where ?

    The capacitors should be small in value (10-20pF) and would go from the
    clock pins to ground.
    Neither of these steps should be necessary and if you have a scope and can
    see that the clock is reliably starting then you don't need them at all.
    However, sometimes the protoboard's stray capacitance and other factors can
    keep the clock from starting and these steps _might_ help.

    Al Williams
    AWC
    * NEW: PAK-IX floating point A/D: http://www.al-williams.com/awce/pak9.htm




    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sign In or Register to comment.