A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
RS232 Level Shifting - Scott Lingerfelt - Jul 30 9:20:00 2005
I need a solution that allows me to communicate with a modem that has
max 3.3Volt interface and my PIC must run at 5Volt due to other
interfacing.
I have been looking at using the MAX3243 to handle the shifting from the
PIC at 5V to 3V then from the modem at 3V to 5V. The only reason I do
not want to use this chip is I only need 1 TX and 1 RX line and the
MAX3243 has 2 TX and 5 RX pins.
Can I use a 2n2222 with the base connected to my PIC UART pin through a
1K ohm resistor, then the collector connected to my modem pin and
through a 1K ohm resistor connected to 3.3V, and the emittor will
connect to ground? I have never tested and would like to know if the
switching will be fast enough for say 9600 baud?
Will the PIC UART pin handle the 3.3V logic directly from the TX of my
modem?
Thanks for any help,
Scott

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - JCullins - Jul 30 9:32:00 2005
You will need to set your pic up for the inverted
signals.
Jim
----- Original Message -----
From: Scott Lingerfelt
To: p...@yahoogroups.com
Sent: Saturday, July 30, 2005 8:20 AM
Subject: [piclist] RS232 Level Shifting
I need a solution that allows me to communicate with a modem that
has
max 3.3Volt interface and my PIC must run at 5Volt due to other
interfacing.
I have been looking at using the MAX3243 to handle the shifting
from the
PIC at 5V to 3V then from the modem at 3V to 5V. The only reason I do
not want to use this chip is I only need 1 TX and 1 RX line and the
MAX3243
has 2 TX and 5 RX pins.
Can I use a 2n2222 with the base connected to my PIC
UART pin through a
1K ohm resistor, then the collector connected to my modem pin and
through a 1K ohm resistor connected to 3.3V, and the emittor will
connect to
ground? I have never tested and would like to know if the
switching will be
fast enough for say 9600 baud?
Will the PIC UART pin handle the 3.3V logic
directly from the TX of my
modem?
Thanks for any help,
Scott

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - Scott Lingerfelt - Jul 30 9:50:00 2005
Hi Jim,
Inverted with the 2n2222?
I believe the pic can handle the 3.3V from my modem without adding any
components. Do you have any input on this?
Thanks for your input,
Scott
JCullins wrote:
> You will need to set your pic up for the inverted signals.
> Jim
>
> ----- Original Message -----
> *From:* Scott Lingerfelt <mailto:slingerfelt@slin...>
> *To:* piclist@picl... <mailto:piclist@picl...>
> *Sent:* Saturday, July 30, 2005 8:20 AM
> *Subject:* [piclist] RS232 Level Shifting
>
> I need a solution that allows me to communicate with a modem that has
> max 3.3Volt interface and my PIC must run at 5Volt due to other
> interfacing.
>
> I have been looking at using the MAX3243 to handle the shifting
> from the
> PIC at 5V to 3V then from the modem at 3V to 5V. The only reason
> I do
> not want to use this chip is I only need 1 TX and 1 RX line and the
> MAX3243 has 2 TX and 5 RX pins.
>
> Can I use a 2n2222 with the base connected to my PIC UART pin
> through a
> 1K ohm resistor, then the collector connected to my modem pin and
> through a 1K ohm resistor connected to 3.3V, and the emittor will
> connect to ground? I have never tested and would like to know if the
> switching will be fast enough for say 9600 baud?
>
> Will the PIC UART pin handle the 3.3V logic directly from the TX
> of my
> modem?
>
> Thanks for any help,
> Scott
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> ------------------------------------------------------------------------
> >.
> ------------------------------------------------------------------------
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - JCullins - Jul 30 10:04:00 2005
What I meant is you will need to change the code to be compatible
with the
fact that the signal will be inverted by the
transistor.
I would add the second transistor to make sure you get a good
level in to the Pic and to keep both input and outputs inverted.
Jim
----- Original Message -----
From: Scott Lingerfelt
To: p...@yahoogroups.com
Sent: Saturday, July 30, 2005 8:50 AM
Subject: Re: [piclist] RS232 Level Shifting
Hi Jim,
Inverted with the 2n2222?
I
believe the pic can handle the 3.3V from my modem without adding any
components. Do you have any input on this?
Thanks for your input,
ScottJCullins wrote:
> You will need to set your pic up for the inverted
signals.
> Jim
>
> ----- Original Message
-----
> *From:* Scott Lingerfelt
<mailto:s...@covcable.com>
> *To:*
p...@yahoogroups.com <mailto:p...@yahoogroups.com>
>
*Sent:* Saturday, July 30, 2005 8:20 AM
> *Subject:*
[piclist] RS232 Level Shifting
>
> I need a
solution that allows me to communicate with a modem that has
> max 3.3Volt interface and my PIC must run at 5Volt due to
other
> interfacing.
>
> I have been looking at using the MAX3243 to handle the
shifting
> from the
> PIC
at 5V to 3V then from the modem at 3V to 5V. The only reason
> I do
> not want to use this
chip is I only need 1 TX and 1 RX line and the
> MAX3243
has 2 TX and 5 RX pins.
>
> Can I use a 2n2222
with the base connected to my PIC UART pin
> through a
> 1K ohm resistor, then the collector connected to my modem
pin and
> through a 1K ohm resistor connected to 3.3V, and
the emittor will
> connect to ground? I have never
tested and would like to know if the
> switching will be
fast enough for say 9600 baud?
>
> Will the PIC
UART pin handle the 3.3V logic directly from the TX
> of
my
> modem?
>
>
Thanks for any help,
> Scott>
> to unsubscribe, go to http://www.yahoogroups.com and follow
the
> instructions>
------------------------------------------------------------------------
> >.>
------------------------------------------------------------------------
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG
Anti-Virus.
>Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date:
7/28/2005
>

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - Scott Lingerfelt - Jul 30 10:15:00 2005
Correct!
I will add the second transistor it cannot hurt!
Thanks for the speedy response,
Scott
JCullins wrote:
> What I meant is you will need to change the code to be compatible with
> the
> fact that the signal will be inverted by the transistor.
>
> I would add the second transistor to make sure you get a good level in
> to the Pic and to keep both input and outputs inverted.
> Jim
>
> ----- Original Message -----
> *From:* Scott Lingerfelt <mailto:slingerfelt@slin...>
> *To:* piclist@picl... <mailto:piclist@picl...>
> *Sent:* Saturday, July 30, 2005 8:50 AM
> *Subject:* Re: [piclist] RS232 Level Shifting
>
> Hi Jim,
>
> Inverted with the 2n2222?
>
> I believe the pic can handle the 3.3V from my modem without adding
> any
> components. Do you have any input on this?
>
> Thanks for your input,
> Scott
> JCullins wrote:
>
> > You will need to set your pic up for the inverted signals.
> > Jim
> >
> > ----- Original Message -----
> > *From:* Scott Lingerfelt <mailto:slingerfelt@slin...>
> > *To:* piclist@picl... <mailto:piclist@picl...>
> > *Sent:* Saturday, July 30, 2005 8:20 AM
> > *Subject:* [piclist] RS232 Level Shifting
> >
> > I need a solution that allows me to communicate with a modem
> that has
> > max 3.3Volt interface and my PIC must run at 5Volt due to other
> > interfacing.
> >
> > I have been looking at using the MAX3243 to handle the shifting
> > from the
> > PIC at 5V to 3V then from the modem at 3V to 5V. The only
> reason
> > I do
> > not want to use this chip is I only need 1 TX and 1 RX line
> and the
> > MAX3243 has 2 TX and 5 RX pins.
> >
> > Can I use a 2n2222 with the base connected to my PIC UART pin
> > through a
> > 1K ohm resistor, then the collector connected to my modem
> pin and
> > through a 1K ohm resistor connected to 3.3V, and the emittor
> will
> > connect to ground? I have never tested and would like to
> know if the
> > switching will be fast enough for say 9600 baud?
> >
> > Will the PIC UART pin handle the 3.3V logic directly from the TX
> > of my
> > modem?
> >
> > Thanks for any help,
> > Scott
> >
> >
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > instructions
> >
> >
> >
> ------------------------------------------------------------------------
> > >.
> >
> >
> >
> ------------------------------------------------------------------------
> >
> >------------------------------------------------------------------------
> >
> >No virus found in this incoming message.
> >Checked by AVG Anti-Virus.
> >Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date:
> 7/28/2005
> >
>
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> ------------------------------------------------------------------------
> >.
> ------------------------------------------------------------------------
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Pic speed controller - Lez - Jul 30 20:07:00 2005
Hi,
I have not programmed a pic in years, since about 99 when the 16cf84 was
the most used around, and even then it was for simple slow things, ie
door / window open-close etc with limit switches so no great master
pieces. (oh and the usual light flashers for the kids)
I now need to build a motor speed control, the motor is to be controlled
by a servo(standard pwm as used in RC cars etc) driven speed controller,
with an inductive pickup to sense the speed, from about 100 to 4000 rpm.
I can easily get a nice square wave from the pickup.
I need to be able to control the motor with a series of switches:
1) Start control and maintain current rpm
2) go faster
3) slow down
4) STOP! (active high) stop pwm output
5) STOP! (active low) stop pwm output
I would also like an output of current pwm value on 3 lines that can
drive a 3 to 8 line converter to run 8 led's to give a remote indication
of the servo position.
If the speed cant be maintained, ie pwm=100% for say more than 30
seconds, it should bleep for a few seconds and power down.
If speed cant be decreased after trying for more than 60 seconds, it
should power down, and bleep a piezo for a few seconds then standby.
Also I would like to be able to send a serial command to it to set a
certain rpm and to query the rpm
I think I can do most of this myself, except for the last bit, the
serial data, but I could live without it, problem is the pwm must be
maintained nearly all the time, although provided servo power is removed
before pwm, it should not move the servo (and hopefully not jump about
when power is re-applied). I think turning it off for a second should be
ok as the motor should not run away in 1 second, this would allow switch
polling to take place. (4 & 5, stop!, need to be polled much faster though)
I thought maybe a 16f88 ? (hope my old 84 programmer can do these)
I just ordered some of these to build a serial to relay board and a
serial input board, so any ideas about the serial would be welcome!
Lez.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - Vasile Surducan - Jul 31 11:55:00 2005
--- In piclist@picl..., Scott Lingerfelt <slingerfelt@c...>
wrote:
> I need a solution that allows me to communicate with a modem that
has
> max 3.3Volt interface and my PIC must run at 5Volt due to other
> interfacing.
>
> I have been looking at using the MAX3243 to handle the shifting
from the
> PIC at 5V to 3V then from the modem at 3V to 5V. The only reason I
do
> not want to use this chip is I only need 1 TX and 1 RX line and the
> MAX3243 has 2 TX and 5 RX pins.
This problem should be easy, an open colector from the 3 to 5 V
interface and one resistor from 5 to 3V interface. However, I've
work recently with a nice chip, it's bidirectional but doesn't count
that: MAX3372. Better for you MAX3375. Very nice in SOT23-8 package.
cheers,
Vasile

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Pic speed controller - Dave Mucha - Jul 31 13:04:00 2005
--- In piclist@picl..., Lez <lez.briddon@n...> wrote:
>
> Hi,
> I have not programmed a pic in years, since about 99 when the 16cf84
was
> the most used around, and even then it was for simple slow things, ie
> door / window open-close etc with limit switches so no great master
> pieces. (oh and the usual light flashers for the kids)
>
> I now need to build a motor speed control, the motor is to be
controlled
> by a servo(standard pwm as used in RC cars etc) driven speed
controller,
> with an inductive pickup to sense the speed, from about 100 to 4000 rpm.
>
> I can easily get a nice square wave from the pickup.
>
> I need to be able to control the motor with a series of switches:
>
> 1) Start control and maintain current rpm
> 2) go faster
> 3) slow down
> 4) STOP! (active high) stop pwm output
> 5) STOP! (active low) stop pwm output
> I would also like an output of current pwm value on 3 lines that can
> drive a 3 to 8 line converter to run 8 led's to give a remote
indication
> of the servo position.
Can you offer a little more details here ? I am familiar with DC
motors that have posistion feedback and run at high speed. For CNC
stuff, these are called servos.
I am also familair with small hobby devices that move some very
limited travle of less than one revolution. these are also called
servos and are used for things like steering in robots and such.
It appears you are talking about something similar by having a
posiston feedback but also a fully rotating unit that will be moving
over some minutes.
Dave

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Re: Pic speed controller - Eirik Karlsen - Jul 31 14:11:00 2005
Dave,
I think it is safe to say that it is "dangerous" to start messing with
feedback (closing the loop)...
May work ok if you'll accept very slow response and low precision.
In some cases one can get away with the simplest loop possible; measure
speed, compare it
to desired speed, and drive the motor in the correct direction with
the amplified difference.
But you won't get any real performance from such a simple scheme ...either
the speedholding
capability is inadequate, or if you turn up the loop gain the system
starts oscillating.
If you want feedback and both speed AND precision things get much much
more complicated,
typically some PID algorithm is needed to stabilize the loop to get
speed, precision and power at the same time.
My latest PIC project actually was such a (modified) PID motor control.
And I must say it is impressive to
see a 200oz DC motor running at 1K RPM comming to a dead stop in less
than 10mS, and with less than
20deg (200 counts) overshoot !
Just Google for something like "pic dc motor control", should turn up
hundreds of interesting results.
Dave Mucha wrote:
--- In p...@yahoogroups.com, Lez <lez.briddon@n...>
wrote:
>
> Hi,
>
>
> I have not programmed a pic in years, since about 99 when the
16cf84
was
> the most used around, and even then it was for simple slow things,
ie
> door / window open-close etc with limit switches so no great
master
> pieces. (oh and the usual light flashers for the kids)
>
> I now need to build a motor speed control, the motor is to be
controlled
> by a servo(standard pwm as used in RC cars etc) driven speed
controller,
> with an inductive pickup to sense the speed, from about 100 to
4000 rpm.
>
> I can easily get a nice square wave from the pickup.
>
> I need to be able to control the motor with a series of switches:
>
> 1) Start control and maintain current rpm
> 2) go faster
> 3) slow down
> 4) STOP! (active high) stop pwm output
> 5) STOP! (active low) stop pwm output
>
>
> I would also like an output of current pwm value on 3 lines that
can
> drive a 3 to 8 line converter to run 8 led's to give a remote
indication
> of the servo position.
Can you offer a little more details here ? I am familiar with
DC
motors that have posistion feedback and run at high speed.
For CNC
stuff, these are called servos.
I am also familair with small hobby devices that move some very
limited travle of less than one revolution. these are also
called
servos and are used for things like steering in robots and such.
It appears you are talking about something similar by having a
posiston feedback but also a fully rotating unit that will be moving
over some minutes.
Dave
--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Pic speed controller - Dave Mucha - Jul 31 14:43:00 2005
--- In piclist@picl..., Eirik Karlsen <eikarlse@o...> wrote:
> Dave,
> I think it is safe to say that it is "dangerous" to start messing with
> feedback (closing the loop)...
> May work ok if you'll accept very slow response and low precision.
> In some cases one can get away with the simplest loop possible; measure
> speed, compare it
> to desired speed, and drive the motor in the correct direction with the
> amplified difference.
> But you won't get any real performance from such a simple scheme
> ...either the speedholding
> capability is inadequate, or if you turn up the loop gain the system
> starts oscillating.
Not necessarialy. If you look at the treadmill SCR drives, or pretty
much any of the 1hp SCR drives, they have a sense resistor across the
motor output to help determine the motor operation. the output of the
controller is really noisy. it jumps around so much that measuring it
is almost useless. I think it might be like measuing the voltage of a
PWM signal. it is either 5v or 0v and has little relation of the average.
I agree 100% that once you start down the road of monitoring and
controlling, the complexity starts to expand.
My applicatios in machine control use the feedback to maintain speed
to a percent or less. And when the rotatinal posistion is used, for
threading or some such, one can move the tool to cooresond to the
speed instead of trying to regulate speed more accuratly.
Dave

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: RS232 Level Shifting - Michael Puchol - Jul 31 17:23:00 2005
Hi Scott,
The PIC will understand the 3.3V no problem, as for the modem, if your
PIC is outputing 5V, simply use a voltage divider to notch down to 3.3V.
I've used this with GSM modems that have CMOS-level UARTS (2.8V) and it
works just fine. Two resistors is all it takes :)
Regards,
Mike
Scott Lingerfelt wrote:
> I need a solution that allows me to communicate with a modem that has
> max 3.3Volt interface and my PIC must run at 5Volt due to other
> interfacing.
>
> I have been looking at using the MAX3243 to handle the shifting from the
> PIC at 5V to 3V then from the modem at 3V to 5V. The only reason I do
> not want to use this chip is I only need 1 TX and 1 RX line and the
> MAX3243 has 2 TX and 5 RX pins.
>
> Can I use a 2n2222 with the base connected to my PIC UART pin through a
> 1K ohm resistor, then the collector connected to my modem pin and
> through a 1K ohm resistor connected to 3.3V, and the emittor will
> connect to ground? I have never tested and would like to know if the
> switching will be fast enough for say 9600 baud?
>
> Will the PIC UART pin handle the 3.3V logic directly from the TX of my
> modem?
>
> Thanks for any help,
> Scott
>
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
> Yahoo! Groups Links

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Re: Pic speed controller - Lez - Jul 31 18:45:00 2005
Dave Mucha wrote:
>
> Can you offer a little more details here ? I am familiar with DC
Ahh sorry did not know that other servo's where called servo's, if you
see what I mean.
In the design I will have to come up with I will be controling the
motors speed with an rc servo linked with a gear to the main speed
control ,these servos have a (I believe) a 10-90% pwm at 20ms.
Its the serial bit that worries me, I have found an old 16f84 so I will
hunt out the programmer and start to play soon, shame I will have to
start with picbasic, I knew all that time ago I should have learned pic
assembler.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Pic speed controller - Dave Mucha - Aug 1 12:39:00 2005
--- In piclist@picl..., Lez <lez.briddon@n...> wrote:
> Dave Mucha wrote:
> >
> >
> >
> > Can you offer a little more details here ? I am familiar with DC
>
> Ahh sorry did not know that other servo's where called servo's, if you
> see what I mean.
>
> In the design I will have to come up with I will be controling the
> motors speed with an rc servo linked with a gear to the main speed
> control ,these servos have a (I believe) a 10-90% pwm at 20ms.
So, it sounds like you want to use the servo to spin a pot or some such ?
> Its the serial bit that worries me,
There are a couple serial ways to go, SPI and I2C being the most common.
What do you need the serial to do ?
>I have found an old 16f84 so I will
> hunt out the programmer and start to
> play soon, shame I will have to
> start with picbasic, I knew all
> that time ago I should have learned pic
> assembler.
PIC-basic might be a lot easier for the serial parts than you think.
Dave

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Re: Pic speed controller - Lez - Aug 2 4:42:00 2005
Dave Mucha wrote:
>>>Can you offer a little more details here ? I am familiar with DC
>>Ahh sorry did not know that other servo's where called servo's, if you
>>see what I mean.
>
> So, it sounds like you want to use the servo to spin a pot or some such ?
>
Pull a throttle arm.
Best way for me to control is to use a model RC servo, rebuilt so it can
pull with a bit more force, on to the original motors speedcontrol,
which is a mechanical throttle arrangement.
>
>
>>Its the serial bit that worries me,
> There are a couple serial ways to go, SPI and I2C being the most common.
>
> What do you need the serial to do ?
I want to be able to work the pic via serial, to perform like the manual
buttons on the pic, Ie send a command to mimic the'go faster' button or
the stop button. Thiswould allow me to be able to control it from a
remote location with a VB program or just a terminal.
Thats why I also needed a command to return a value that represents the
motors speed (rpm probably best form of result)
>
> PIC-basic might be a lot easier for the serial parts than you think.
Well I have found 1 old 84' and a model car servo, now I just need to
find where I put the programmer.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )