PWM and I2COUT
Archiver
Posts: 46,084
Dear all,
I've some difficulties, hope someone can help me, thanks!!!
I've connected a 24LC32A to the BS2p-40 and write out the following
prog:
Buf VAR Byte
I2COUT 0,SA0,0[noparse][[/noparse]120]
Pause 500
I2CIN 0,SA1,0[noparse][[/noparse]Buf]
DEBUG DEC Buf
Assuming that "120" would be printed out after running the program,
however "255" was printed out rather than "120".
Does anyone know what wrong is my program and why "255" is come out?
How many EEPROM that can I use with BASIC STAMP?
Besides, how I generate a PWM signal with 500kHz? by using PWM
command? What value of resistor and capacitor should I used?
Thank you very much!!!!
I've some difficulties, hope someone can help me, thanks!!!
I've connected a 24LC32A to the BS2p-40 and write out the following
prog:
Buf VAR Byte
I2COUT 0,SA0,0[noparse][[/noparse]120]
Pause 500
I2CIN 0,SA1,0[noparse][[/noparse]Buf]
DEBUG DEC Buf
Assuming that "120" would be printed out after running the program,
however "255" was printed out rather than "120".
Does anyone know what wrong is my program and why "255" is come out?
How many EEPROM that can I use with BASIC STAMP?
Besides, how I generate a PWM signal with 500kHz? by using PWM
command? What value of resistor and capacitor should I used?
Thank you very much!!!!
Comments
$A1 for reading from eeprom.
Do you have two 4.7K pull-ups on I/O lines P0 and P1?
not sure about PWM but believe it is mainly used to produce a voltage out
however it will produce rather low frequency. If you want higher frequency
out use the FREQOUT command but it is only limited to 32Khz
If you need higher frequency out, take a look at Al Williams PAC-V chip.
http://www.al-williams.com/pak5.htm
Daryl
At 07:36 PM 5/17/2004, you wrote:
>Dear all,
>
>I've some difficulties, hope someone can help me, thanks!!!
>I've connected a 24LC32A to the BS2p-40 and write out the following
>prog:
>
>Buf VAR Byte
>I2COUT 0,SA0,0[noparse][[/noparse]120]
>Pause 500
>I2CIN 0,SA1,0[noparse][[/noparse]Buf]
>DEBUG DEC Buf
>
>Assuming that "120" would be printed out after running the program,
>however "255" was printed out rather than "120".
>Does anyone know what wrong is my program and why "255" is come out?
>How many EEPROM that can I use with BASIC STAMP?
>
>Besides, how I generate a PWM signal with 500kHz? by using PWM
>command? What value of resistor and capacitor should I used?
>
>Thank you very much!!!!
>
>
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and
>Body of the message will be ignored.
>
>Yahoo! Groups Links
>
>
>
>
$A1.
I have connect the two 4.7K resistors.
Are there any mistake in my program??
Thanks!!
--- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
wrote:
>
> Did you mean SA0 be a variable or did you mean $A0 for writing and
SA1 be
> $A1 for reading from eeprom.
> Do you have two 4.7K pull-ups on I/O lines P0 and P1?
>
> not sure about PWM but believe it is mainly used to produce a
voltage out
> however it will produce rather low frequency. If you want higher
frequency
> out use the FREQOUT command but it is only limited to 32Khz
> If you need higher frequency out, take a look at Al Williams PAC-V
chip.
> http://www.al-williams.com/pak5.htm
>
> Daryl
>
>
> At 07:36 PM 5/17/2004, you wrote:
> >Dear all,
> >
> >I've some difficulties, hope someone can help me, thanks!!!
> >I've connected a 24LC32A to the BS2p-40 and write out the following
> >prog:
> >
> >Buf VAR Byte
> >I2COUT 0,SA0,0[noparse][[/noparse]120]
> >Pause 500
> >I2CIN 0,SA1,0[noparse][[/noparse]Buf]
> >DEBUG DEC Buf
> >
> >Assuming that "120" would be printed out after running the program,
> >however "255" was printed out rather than "120".
> >Does anyone know what wrong is my program and why "255" is come
out?
> >How many EEPROM that can I use with BASIC STAMP?
> >
> >Besides, how I generate a PWM signal with 500kHz? by using PWM
> >command? What value of resistor and capacitor should I used?
> >
> >Thank you very much!!!!
> >
> >
that I overlooked. On this particular EEPROM 24LC32A it requires 2 address
bytes, high word first then the low word. actually only 12 bits are used
internally. Also to read the data back you must send the same address byte
along with the data in two separate transactions. sometimes it helps to
look at the data sheet twice or three times. at least for me anyway. try
to change the code something like this.
' comments in bold are the changes
Buf VAR Byte
I2COUT 0,$A0,0,0,[noparse][[/noparse]120] ' send data "120" to address location $00 MSB
first (16 bit address) using I/O pins P0, P1
Pause 500
I2CIN 0,SA1,0,0,[noparse][[/noparse]Buf] ' setup a random read at address location $00
MSB first
I2CIN 0,SA1,[noparse][[/noparse]Buf] ' read data in var "Buf"
DEBUG DEC Buf
try this, haven't tested it but thinking it should work
Daryl
At 02:43 AM 5/18/2004, you wrote:
>hi Daryl, I'm sorry that I've make a mistake. It should be $A0 and
>$A1.
>I have connect the two 4.7K resistors.
>Are there any mistake in my program??
>Thanks!!
>
>
>--- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
>wrote:
> >
> > Did you mean SA0 be a variable or did you mean $A0 for writing and
>SA1 be
> > $A1 for reading from eeprom.
> > Do you have two 4.7K pull-ups on I/O lines P0 and P1?
> >
> > not sure about PWM but believe it is mainly used to produce a
>voltage out
> > however it will produce rather low frequency. If you want higher
>frequency
> > out use the FREQOUT command but it is only limited to 32Khz
> > If you need higher frequency out, take a look at Al Williams PAC-V
>chip.
> > http://www.al-williams.com/pak5.htm
> >
> > Daryl
> >
> >
> > At 07:36 PM 5/17/2004, you wrote:
> > >Dear all,
> > >
> > >I've some difficulties, hope someone can help me, thanks!!!
> > >I've connected a 24LC32A to the BS2p-40 and write out the following
> > >prog:
> > >
> > >Buf VAR Byte
> > >I2COUT 0,SA0,0[noparse][[/noparse]120]
> > >Pause 500
> > >I2CIN 0,SA1,0[noparse][[/noparse]Buf]
> > >DEBUG DEC Buf
> > >
> > >Assuming that "120" would be printed out after running the program,
> > >however "255" was printed out rather than "120".
> > >Does anyone know what wrong is my program and why "255" is come
>out?
> > >How many EEPROM that can I use with BASIC STAMP?
> > >
> > >Besides, how I generate a PWM signal with 500kHz? by using PWM
> > >command? What value of resistor and capacitor should I used?
> > >
> > >Thank you very much!!!!
> > >
> > >
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and
>Body of the message will be ignored.
>
>Yahoo! Groups Links
>
>
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
apparently bold text is not an option. Ok lets see if this looks better
Quoting Daryl Berryhill <djberry@h...>:
Ahhh! I should slap myself. Looking at the code again there is
something that I overlooked. On this particular EEPROM 24LC32A it requires 2
address bytes, high word first then the low word. actually only 12 bits are
used internally. Also to read the data back you must send the same address
byte along with the data in two separate transactions. sometimes it helps to
look at the data sheet twice or three times. at least for me anyway.
try to change the code something like this.
' comments in bold are the changes
Buf VAR Byte
' send data "120" to address location $00 MSB
' first (16 bit address) using I/O pins P0, P1
I2COUT 0,$A0,0,0,[noparse][[/noparse]120]
Pause 500
' setup a random read at address location $00
' must setup the address first then read the data
I2CIN 0,$A1,0,0,[noparse][[/noparse]Buf]
I2CIN 0,$A1,[noparse][[/noparse]Buf] ' read data in var "Buf"
DEBUG DEC Buf
try this, haven't tested it but thinking it should work
Daryl
> At 02:43 AM 5/18/2004, you wrote:
> >hi Daryl, I'm sorry that I've make a mistake. It should be $A0 and
> >$A1.
> >I have connect the two 4.7K resistors.
> >Are there any mistake in my program??
> >Thanks!!
> >
> >
> >--- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
> >wrote:
> > >
> > > Did you mean SA0 be a variable or did you mean $A0 for writing and
> >SA1 be
> > > $A1 for reading from eeprom.
> > > Do you have two 4.7K pull-ups on I/O lines P0 and P1?
> > >
> > > not sure about PWM but believe it is mainly used to produce a
> >voltage out
> > > however it will produce rather low frequency. If you want higher
> >frequency
> > > out use the FREQOUT command but it is only limited to 32Khz
> > > If you need higher frequency out, take a look at Al Williams PAC-V
> >chip.
> > > http://www.al-williams.com/pak5.htm
> > >
> > > Daryl
> > >
> > >
> > > At 07:36 PM 5/17/2004, you wrote:
> > > >Dear all,
> > > >
> > > >I've some difficulties, hope someone can help me, thanks!!!
> > > >I've connected a 24LC32A to the BS2p-40 and write out the
> following
> > > >prog:
> > > >
> > > >Buf VAR Byte
> > > >I2COUT 0,SA0,0[noparse][[/noparse]120]
> > > >Pause 500
> > > >I2CIN 0,SA1,0[noparse][[/noparse]Buf]
> > > >DEBUG DEC Buf
> > > >
> > > >Assuming that "120" would be printed out after running the
> program,
> > > >however "255" was printed out rather than "120".
> > > >Does anyone know what wrong is my program and why "255" is come
> >out?
> > > >How many EEPROM that can I use with BASIC STAMP?
> > > >
> > > >Besides, how I generate a PWM signal with 500kHz? by using PWM
> > > >command? What value of resistor and capacitor should I used?
> > > >
> > > >Thank you very much!!!!
> > > >
> > > >
> >
> >
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> >from the same email address that you subscribed. Text in the Subject
> and
> >Body of the message will be ignored.
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
>
>
I2COUT Pin, SlaveID, {Address {\LowAddress},} [noparse][[/noparse]OutputData]
so for the example below it would be:
I2COUT 0, $A0, 0\0, [noparse][[/noparse]120]
Remember, correct syntax for PBASIC instructions is just a click away
(Help file).
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Daryl Berryhill [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XmkRBpn5OmsySftYTYsxl6p7oTGzGPXfjh8Pb-dq8MAMZhBl1aeOwRX1aqX1e7C0nAUemNskyj5lTg]djberry@h...[/url
Sent: Tuesday, May 18, 2004 6:10 AM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Re: PWM and I2COUT
Ahhh! I should slap myself. Looking at the code again there is
something
that I overlooked. On this particular EEPROM 24LC32A it requires 2
address
bytes, high word first then the low word. actually only 12 bits are used
internally. Also to read the data back you must send the same address
byte
along with the data in two separate transactions. sometimes it helps to
look at the data sheet twice or three times. at least for me anyway.
try
to change the code something like this.
' comments in bold are the changes
Buf VAR Byte
I2COUT 0,$A0,0,0,[noparse][[/noparse]120] ' send data "120" to address location $00 MSB
first (16 bit address) using I/O pins P0, P1
Pause 500
I2CIN 0,SA1,0,0,[noparse][[/noparse]Buf] ' setup a random read at address location
$00
MSB first
I2CIN 0,SA1,[noparse][[/noparse]Buf] ' read data in var "Buf"
DEBUG DEC Buf
try this, haven't tested it but thinking it should work
Daryl
At 02:43 AM 5/18/2004, you wrote:
>hi Daryl, I'm sorry that I've make a mistake. It should be $A0 and $A1.
>I have connect the two 4.7K resistors.
>Are there any mistake in my program??
>Thanks!!
>
>
>--- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
>wrote:
> >
> > Did you mean SA0 be a variable or did you mean $A0 for writing and
>SA1 be
> > $A1 for reading from eeprom.
> > Do you have two 4.7K pull-ups on I/O lines P0 and P1?
> >
> > not sure about PWM but believe it is mainly used to produce a
>voltage out
> > however it will produce rather low frequency. If you want higher
>frequency
> > out use the FREQOUT command but it is only limited to 32Khz If you
> > need higher frequency out, take a look at Al Williams PAC-V
>chip.
> > http://www.al-williams.com/pak5.htm
> >
> > Daryl
> >
> >
> > At 07:36 PM 5/17/2004, you wrote:
> > >Dear all,
> > >
> > >I've some difficulties, hope someone can help me, thanks!!! I've
> > >connected a 24LC32A to the BS2p-40 and write out the following
> > >prog:
> > >
> > >Buf VAR Byte
> > >I2COUT 0,SA0,0[noparse][[/noparse]120]
> > >Pause 500
> > >I2CIN 0,SA1,0[noparse][[/noparse]Buf]
> > >DEBUG DEC Buf
> > >
> > >Assuming that "120" would be printed out after running the program,
> > >however "255" was printed out rather than "120". Does anyone know
> > >what wrong is my program and why "255" is come
>out?
> > >How many EEPROM that can I use with BASIC STAMP?
> > >
> > >Besides, how I generate a PWM signal with 500kHz? by using PWM
> > >command? What value of resistor and capacitor should I used?
> > >
> > >Thank you very much!!!!
> > >
> > >
I get for getting for not testing the code first.
Yes, love the PBASIC help file. It stays open most of the time. wish it had
more examples tho. Another good friend to have the datasheets of the components
your working with.
Quoting Jon Williams <jwilliams@p...>:
> The formatting for two-byte addresses is:
>
> I2COUT Pin, SlaveID, {Address {\LowAddress},} [noparse][[/noparse]OutputData]
>
> so for the example below it would be:
>
> I2COUT 0, $A0, 0\0, [noparse][[/noparse]120]
>
> Remember, correct syntax for PBASIC instructions is just a click away
> (Help file).
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
>
Original Message
> From: Daryl Berryhill [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7ckwqMRPiO_JdbKpmOC3DTBMarcLh2VKMs1zLvRa6SwXUttC0WFzvJT-k1kuPWy4GbnCHjRFbCm-WA]djberry@h...[/url
> Sent: Tuesday, May 18, 2004 6:10 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Re: PWM and I2COUT
>
>
> Ahhh! I should slap myself. Looking at the code again there is
> something
> that I overlooked. On this particular EEPROM 24LC32A it requires 2
> address
> bytes, high word first then the low word. actually only 12 bits are
> used
>
> internally. Also to read the data back you must send the same address
> byte
> along with the data in two separate transactions. sometimes it helps to
>
> look at the data sheet twice or three times. at least for me anyway.
> try
> to change the code something like this.
>
> ' comments in bold are the changes
>
> Buf VAR Byte
> I2COUT 0,$A0,0,0,[noparse][[/noparse]120] ' send data "120" to address location $00 MSB
>
> first (16 bit address) using I/O pins P0, P1
> Pause 500
> I2CIN 0,SA1,0,0,[noparse][[/noparse]Buf] ' setup a random read at address location
> $00
> MSB first
> I2CIN 0,SA1,[noparse][[/noparse]Buf] ' read data in var "Buf"
> DEBUG DEC Buf
>
> try this, haven't tested it but thinking it should work
>
> Daryl
>
>
> At 02:43 AM 5/18/2004, you wrote:
> >hi Daryl, I'm sorry that I've make a mistake. It should be $A0 and
> $A1.
> >I have connect the two 4.7K resistors.
> >Are there any mistake in my program??
> >Thanks!!
> >
> >
> >--- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
> >wrote:
> > >
> > > Did you mean SA0 be a variable or did you mean $A0 for writing and
> >SA1 be
> > > $A1 for reading from eeprom.
> > > Do you have two 4.7K pull-ups on I/O lines P0 and P1?
> > >
> > > not sure about PWM but believe it is mainly used to produce a
> >voltage out
> > > however it will produce rather low frequency. If you want higher
> >frequency
> > > out use the FREQOUT command but it is only limited to 32Khz If you
>
> > > need higher frequency out, take a look at Al Williams PAC-V
> >chip.
> > > http://www.al-williams.com/pak5.htm
> > >
> > > Daryl
> > >
> > >
> > > At 07:36 PM 5/17/2004, you wrote:
> > > >Dear all,
> > > >
> > > >I've some difficulties, hope someone can help me, thanks!!! I've
> > > >connected a 24LC32A to the BS2p-40 and write out the following
> > > >prog:
> > > >
> > > >Buf VAR Byte
> > > >I2COUT 0,SA0,0[noparse][[/noparse]120]
> > > >Pause 500
> > > >I2CIN 0,SA1,0[noparse][[/noparse]Buf]
> > > >DEBUG DEC Buf
> > > >
> > > >Assuming that "120" would be printed out after running the
> program,
>
> > > >however "255" was printed out rather than "120". Does anyone know
>
> > > >what wrong is my program and why "255" is come
> >out?
> > > >How many EEPROM that can I use with BASIC STAMP?
> > > >
> > > >Besides, how I generate a PWM signal with 500kHz? by using PWM
> > > >command? What value of resistor and capacitor should I used?
> > > >
> > > >Thank you very much!!!!
> > > >
> > > >
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
>
>
But I still have another problem that need your help. I've download
the following program to the BS2p-40, it work, "2" is printed out.
However, if I use the MAINIO rather than AUXIO, problem is aroused.
Pls refer to the lowest part of this message, it doesn't work. "255"
is printed out rather than "2". Can anyone give me some advice?
Besides, if the data of Buf is larger than 8 bits, can I use "word"
rather than "Byte"? If no, what can I do?
Thank you very much!!!!!
**This prog is work**
'{$STAMP BS2p}
'{$PORT COM4}
addr VAR Word
hi VAR addr.HIGHBYTE
lo VAR addr.LOWBYTE
out VAR Byte
Buf VAR Byte
out = 2
addr = 5
AUXIO
I2COUT 8,$A0,hi\lo,[noparse][[/noparse]out]
'send data "2" to address location $00 MSB first (16 bit address)
using I/O pins P8, P9
PAUSE 100
I2CIN 8,$A1,hi\lo,[noparse][[/noparse]Buf]
DEBUG DEC Buf
'**THIS PART CAN'T BE RUN:**
I2COUT 0,$A0,hi\lo,[noparse][[/noparse]out] 'send data "2" to address location $00 MSB
first (16 bit address) using I/O pins P0, P1
PAUSE 100
I2CIN 0,$A1,hi\lo,[noparse][[/noparse]Buf]
DEBUG DEC Buf
buf.BTYE0, buf.BYTE1
Just make sure you write and read them the same way
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: ck1_chu [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AocON4NwnnO9X__Rm0zfo9WnhJLHb5PyGlFxEyYv_r1L0AHCX3-100dwzSiAjxeF0YZVwv3k8YmiLw]ck1_chu@y...[/url
Sent: Wednesday, May 19, 2004 10:24 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: PWM and I2COUT
hi Daryl and Jon, thanks very much!! Your program is work!!
But I still have another problem that need your help. I've download
the following program to the BS2p-40, it work, "2" is printed out.
However, if I use the MAINIO rather than AUXIO, problem is aroused.
Pls refer to the lowest part of this message, it doesn't work. "255"
is printed out rather than "2". Can anyone give me some advice?
Besides, if the data of Buf is larger than 8 bits, can I use "word"
rather than "Byte"? If no, what can I do?
Thank you very much!!!!!
**This prog is work**
'{$STAMP BS2p}
'{$PORT COM4}
addr VAR Word
hi VAR addr.HIGHBYTE
lo VAR addr.LOWBYTE
out VAR Byte
Buf VAR Byte
out = 2
addr = 5
AUXIO
I2COUT 8,$A0,hi\lo,[noparse][[/noparse]out]
'send data "2" to address location $00 MSB first (16 bit address)
using I/O pins P8, P9
PAUSE 100
I2CIN 8,$A1,hi\lo,[noparse][[/noparse]Buf]
DEBUG DEC Buf
'**THIS PART CAN'T BE RUN:**
I2COUT 0,$A0,hi\lo,[noparse][[/noparse]out] 'send data "2" to address location $00 MSB
first (16 bit address) using I/O pins P0, P1
PAUSE 100
I2CIN 0,$A1,hi\lo,[noparse][[/noparse]Buf]
DEBUG DEC Buf
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
This message has been scanned by WebShield. Please report SPAM to
abuse@p....