View Full Version : Serin serout problem
lerameur
- 7th January 2007, 20:11
ok I am doing a remote control for my robot I wrote a code below, It seems long, Maybe you have a better idea. I am using two Potentiometer , the values of each will control the left and right motor of the robot:
'Remote control*****************
direction var word : speed var word
Loop:
If (left => 115) AND (left <= 135) AND (right => 115) AND (right <= 135) then
goto stop
If (left => 115) AND (left <= 135) AND (right <= 115) then 'left is stop, right is CCW
goto LeftstopRightCCW
If (left => 115) AND (left <= 135) AND (right => 135) then 'left is stop , right is CW
goto LeftstopRightCW
If (right => 115) AND (right <= 135) AND (right <= 115) then 'right is stop, left is CCW
goto RightstopLeftCCW
If (right => 115) AND (right <= 135) AND (right => 135) then 'right is stop , left is CW
goto RightstopLeftCW
If (left > 135) AND (right > 135) then 'Left Cw & right CW
goto LeftCWRightCW
If (left > 135) AND (right < 135) then 'Left CW & right CCW
goto LeftCWRightCCW
If (left < 135) AND (right > 135) then 'Left CCW & right CW
goto LeftCCWRightCW
If (left < 135) AND (right < 135) then 'Left CCW & right CCW
goto LeftCCWRightCCW
In brief:
'Stop '--------------------------------$69 = 01 10 10 01
'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01
skimask
- 8th January 2007, 03:08
I also have te Pic18F4685, PBP do not have a file to compile this...
How do I go about making an Hex file out of it ??
Upgrade to 2.47...
skimask
- 8th January 2007, 03:23
ok I am doing a remote control for my robot I wrote a code below, It seems long, Maybe you have a better idea. I am using two Potentiometer , the values of each will control the left and right motor of the robot:
'Remote control*****************
direction var word : speed var word
Loop:
If (left => 115) AND (left <= 135) AND (right => 115) AND (right <= 135) then
goto stop
If (left => 115) AND (left <= 135) AND (right <= 115) then 'left is stop, right is CCW
goto LeftstopRightCCW
If (left => 115) AND (left <= 135) AND (right => 135) then 'left is stop , right is CW
goto LeftstopRightCW
If (right => 115) AND (right <= 135) AND (right <= 115) then 'right is stop, left is CCW
goto RightstopLeftCCW
If (right => 115) AND (right <= 135) AND (right => 135) then 'right is stop , left is CW
goto RightstopLeftCW
If (left > 135) AND (right > 135) then 'Left Cw & right CW
goto LeftCWRightCW
If (left > 135) AND (right < 135) then 'Left CW & right CCW
goto LeftCWRightCCW
If (left < 135) AND (right > 135) then 'Left CCW & right CW
goto LeftCCWRightCW
If (left < 135) AND (right < 135) then 'Left CCW & right CCW
goto LeftCCWRightCCW
In brief:
'Stop '--------------------------------$69 = 01 10 10 01
'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01
You're right. There probably is a better/shorter way to do that.
I'll think about it for a bit and get back to ya.
I take it that the reason you've got 115 and 135 is for a bit of a 'deadband' so the thing doesn't jitter on you?
(see that?, the manchester encoding is handy isn't it?)
How about
'Remote control*****************
direction var word : speed var word
bits var byte
'bits = bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
' LCW (-LCW) LCCW -(LCCW) RCW (-RCW) RCCW (-RCCW)
'use odd bits as a direction flag, use the even bits inverted from the others as the same thing, but also as a bit of error detection
TX end...
Loop:
bits = %01010101
If (left => 115) AND (left <= 135) then bits.7 = 0 : bits.6 = 1
if (right => 115) AND (right <= 135) then bits.3 = 0 : bits.2 = 1
if (right <= 115) then bits.1 = 1 : bits.0 = 0
If (right => 135) then bits.3 = 1 : bits.2 = 0
If (left <= 115) then bits.5 = 1 : bits.4 = 0
If (left => 135) then bits.7 = 1 : bits.6 = 0
transmit
goto loop
RX end....
In brief:
if bits.7 = bits.6 then bitserror 'bit pairs shouldn't be equal
if bits.5 = bits.4 then bitserror
if bits.3 = bits.2 then bitserror
if bits.1 = bits.0 then bitserror
'Stop '--------------------------------$69 = 01 10 10 01
'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01
And at the receiver end, the receiver code wouldn't actuate a motor until receiving a few correct codes in a row (a one time code wouldn't trip the motors into running).
Just a quick thought I had...
lerameur
- 10th January 2007, 03:08
I got the module working now, I will be doing some testing thursday.
by the way i wouls like to have a crystal oscillate by itself, How do i do that ? I have a sensor chip that needs to be clocked. I tried connecting it to + and ground but nothing
skimask
- 10th January 2007, 04:26
I got the module working now, I will be doing some testing thursday.
by the way i wouls like to have a crystal oscillate by itself, How do i do that ? I have a sensor chip that needs to be clocked. I tried connecting it to + and ground but nothing
Crystals don't oscillator by themselves. In short, you have to have a small inverting amp, induce a phase shift, and a few other things to get a usable signal from them. Grab the datasheet for a 4066 and see what they do with a crystal and one of those chips. Or just buy a DIP oscillator of the frequency of your choice (Digikey ECS oscillators).
lerameur
- 11th January 2007, 04:56
I got the oscillator goimg, Its square wave, I will be adding a couple of caps and resisor to make it more like a sin wave.
Also I needed more memory for my project so I got the monster Pic18F4685. Iuse the same program as for the Pic16F877a and it gives errors about the nbit number, I guess I have to change all the specification of my program. but I am not sure what; here is the message i am getting after compiling:
C:\PBP>pbp -p18F4685 motorG
PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error 18F4685.INC 14 : [235] Opcode Expected Instead of 'Error: PM does not sup
port this device. Use MPASM.'
Error C:\PBP\MOTORG.ASM 85 : [225] Undefined Symbol 'PORTB'
Error C:\PBP\MOTORG.ASM 86 : [225] Undefined Symbol 'PORTC'
Error C:\PBP\MOTORG.ASM 87 : [225] Undefined Symbol 'TRISB'
Error C:\PBP\MOTORG.ASM 88 : [225] Undefined Symbol 'TRISC'
Error PBPPIC18.LIB 161 : [225] Undefined Symbol 'PORTB'
Error PBPPIC18.LIB 379 : [225] Undefined Symbol 'PORTB'
Error PBPPIC18.LIB 1153 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1153 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1158 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1158 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1281 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1281 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1282 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1282 : [218] Address Limit of FFFFh Exceeded
Fatal PBPPIC18.LIB 1282 : [300] Too Many Errors
C:\PBP>
skimask
- 11th January 2007, 13:39
I got the oscillator goimg, Its square wave, I will be adding a couple of caps and resisor to make it more like a sin wave.
Also I needed more memory for my project so I got the monster Pic18F4685. Iuse the same program as for the Pic16F877a and it gives errors about the nbit number, I guess I have to change all the specification of my program. but I am not sure what; here is the message i am getting after compiling:
C:\PBP>pbp -p18F4685 motorG
PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error 18F4685.INC 14 : [235] Opcode Expected Instead of 'Error: PM does not sup
port this device. Use MPASM.'
Error C:\PBP\MOTORG.ASM 85 : [225] Undefined Symbol 'PORTB'
Error C:\PBP\MOTORG.ASM 86 : [225] Undefined Symbol 'PORTC'
Error C:\PBP\MOTORG.ASM 87 : [225] Undefined Symbol 'TRISB'
Error C:\PBP\MOTORG.ASM 88 : [225] Undefined Symbol 'TRISC'
Error PBPPIC18.LIB 161 : [225] Undefined Symbol 'PORTB'
Error PBPPIC18.LIB 379 : [225] Undefined Symbol 'PORTB'
Error PBPPIC18.LIB 1153 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1153 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1158 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1158 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1281 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1281 : [218] Address Limit of FFFFh Exceeded
Error PBPPIC18.LIB 1282 : [200] Instruction Restricted to 14-Bit Core
Error PBPPIC18.LIB 1282 : [218] Address Limit of FFFFh Exceeded
Fatal PBPPIC18.LIB 1282 : [300] Too Many Errors
C:\PBP>
Check your PBP manual. You can't use the assembler that comes with PBP, gotta use MPASM for the PIC18Fxxxx parts.
lerameur
- 11th January 2007, 16:35
O ok, because i saw the .BAS and .INC files, so I thougt it would take it.
alright
lerameur
- 11th January 2007, 17:12
HI,
I am almost finish writing my code and I get an error at the receivring end, I have an LCDout and the sending end, it good number, but at the receiving end the information is confused.
meaning the Left is showing the same thing as the sending left.
But the right is showing me number like 12421 (pot at center). I encode and decode he same way, This is weird. what also struck me is that number 12421 is constant, so that when I move my pot there is a variation from 12542 to 12288 .
I also flipped the serin line for left and right and i get the same result..
(the sending and show number varying between 0 to 255)
here is a snippet of the code:
right var word : left var word : temp var word : counter var byte
rightold var word : leftold var word : speedright var word : speedleft var word
loop:
waitfor55:
serin portb.2 , n2400 , temp
if temp <> $55 then goto waitfor55
waitforaa:
serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa
serin portb.2, n2400, rightold.LowBYTE : serin portb.2, n2400, rightold.HighBYTE
serin portb.2, n2400, leftold.LowBYTE : serin portb.2, n2400, leftold.HighBYTE
For counter=0 TO 7 'decoding
left.0[counter]=leftold.0[counter*2]
right.0[counter]=rightold.0[counter*2]
Next counter
Lcdout $fe, 1 'Clear screen
Lcdout "Left: ", Dec left
Lcdout $fe, $C0, "Right: ", DEC right
Pause 100
before you ask, here is my sending part:
send:
Lcdout $fe, 1 'Clear screen
Lcdout "Left: ", Dec left
Lcdout $fe, $C0, "Right: ", DEC right
serout portb.2, n2400,[$55,$55,$55,$55,$55,$55,$55,$55,$aa]
serout portb.2, n2400,[rightnew.LowBYTE,rightnew.HighBYTE]
serout portb.2, n2400,[leftnew.LowBYTE,leftnew.HighBYTE]
goto loop
end
lerameur
- 11th January 2007, 18:18
it works now, changed some word to byte ...
lerameur
- 14th January 2007, 17:36
Hey , I just realize that after running my receiving circuit for a minute or so , he Lm7805 gets very hot, Is this normal ?. on my sending circuit it stays cool.
I have on the receiving, an lcd, the receiving RF module, a Pic16F877a and an H-Bridge.. The H bridge is running directly from the battery for the Vs. everything is battery operated
keithdoxey
- 14th January 2007, 17:56
Hey , I just realize that after running my receiving circuit for a minute or so , he Lm7805 gets very hot, Is this normal ?. on my sending circuit it stays cool.
I have on the receiving, an lcd, the receiving RF module, a Pic16F877a and an H-Bridge.. The H bridge is running directly from the battery for the Vs. everything is battery operated
Does the LCD have a backlight ?
If so, try running it from the unregulated power supply after increasing the resistor accordingly.
lerameur
- 14th January 2007, 18:08
yes it does have a backlioght.
The supply is a 12v battery cannot put that directly on thebattery
keithdoxey
- 14th January 2007, 19:36
yes it does have a backlioght.
The supply is a 12v battery cannot put that directly on thebattery
Do you have a series resistor between your 5v supply and the LCD backlight?
If not it will be drawing excessive current which will definately be why the 7805 is cooking.
If you do have a resistor, then increase its value and drive the backlight from the 12v supply. Search for threads about "backlight", one just resurfaced in the last couple of days.
lerameur
- 14th January 2007, 20:04
i have a potenetiometer between the 5 v and the LCD, I swiched to the 12v with the pot, and the LCD is finished :(
keithdoxey
- 14th January 2007, 20:34
i have a potenetiometer between the 5 v and the LCD, I swiched to the 12v with the pot, and the LCD is finished :(
Sorry to hear that you toasted the LCD but I didnt suggest running the LCD from the 12v supply.... just the backlight.
If you had read the other threads about this you would see the reason behind it. The LCD only takes a couple of milliamps but the backlight takes 50-80mA which is a lot of extra for the regulator to handle.
The backlight doesnt need a regulated supply, just a current limited one hence the use of a series resistor which you calculate according to the forward voltage of the backlight , the required current through the backlight and the maximum voltage of the unregulated supply.
lerameur
- 14th January 2007, 21:21
a ok , i get it,
By the way , anybody knows why My h_bridge, L298N get really really hot even with a heat sink and just 1.8 amp ?and yes it is connected to the 12v battery. Getting hot, and its not working anymore...
Archangel
- 15th January 2007, 00:41
a ok , i get it,
By the way , anybody knows why My h_bridge, L298N get really really hot even with a heat sink and just 1.8 amp ?and yes it is connected to the 12v battery. Getting hot, and its not working anymore...
Hi Leramuer, sounds like the magic smoke escaped from that device. 12v x 1.8 a
= 21.6 watts, I assume thats the running current under normal load. That figure increases exponentialy when you reverse direction and that's a whole lot of heat. What do you have for a heat sink? Maybe in addition to more heat sink you should put in a thermal shutdown circuit.
JS
skimask
- 15th January 2007, 01:03
a ok , i get it,
By the way , anybody knows why My h_bridge, L298N get really really hot even with a heat sink and just 1.8 amp ?and yes it is connected to the 12v battery. Getting hot, and its not working anymore...
If it was me doing a project needing an H-bridge, I'd skip the H-bridge and just go with a set up using a bunch of logic-level N-channel enhancement mode MOSFETs (try saying that 3 times fast), or P-channel, whatever. That way I know for sure I can drive whatever it is I need to drive. And if the MOSFETs get too hot even after putting a heatsink on them, you can always parallel them. Which gets me to thinking...have you tried paralleling a couple of L298N's? I haven't read the datasheet, don't know if it's possible (or even wise)...might work though.
And 12v @ 1.8a does = 21.6watts, but only if the L298N has resistance across it, zero resistance = zero load. Maybe the L298N isn't being driven hard enough. (Sounds like it's time to get my butt over to the datasheets so I know what I'm talking about here).
lerameur
- 15th January 2007, 01:42
I have a big ass heat sink, about 9 times he size of the chip.
I believe I was under th wattage recommended (or maybe just on it, cause the battery was fully charged at 12.85 and @ 1.9 amp 24.7 watt.
would that of killed it.
I looked at comse circuit for making my own H-bridge, but is seems a bit messy.
I have some IRFZ44N N mos, maybe get their brother P's and work with that, you have any schematic ?
I found this: http://www.armory.com/~rstevew/Public/Motors/H-Bridges/Blanchard/nch-brdg.htm
but I dont know
update:
I tried one IRFZ44N , it become very hot with just 5watt. I know I can put a heat sink, but this thing is suppose to support 94 watt. Is there somehting I am not getting ??
lerameur
- 15th January 2007, 05:02
to go back to my LCD problem , I am not using backlight. I thought you where refering to the contrast adjustment. nothing is connected to th backlight supply. IS this ,my problem , From the other post you mentionned, The gentlemen did not have a problen and the backlight was not connected. Mine does.
skimask
- 15th January 2007, 06:58
I have a big ass heat sink, about 9 times he size of the chip.
I believe I was under th wattage recommended (or maybe just on it, cause the battery was fully charged at 12.85 and @ 1.9 amp 24.7 watt.
would that of killed it.
I looked at comse circuit for making my own H-bridge, but is seems a bit messy.
I have some IRFZ44N N mos, maybe get their brother P's and work with that, you have any schematic ?
I found this: http://www.armory.com/~rstevew/Public/Motors/H-Bridges/Blanchard/nch-brdg.htm
but I dont know
update:
I tried one IRFZ44N , it become very hot with just 5watt. I know I can put a heat sink, but this thing is suppose to support 94 watt. Is there somehting I am not getting ??
Well, like I said, the only way something can dissipate heat is if it has resistance in the first place, zero ohms across a device = zero volts dropped across it = zero watts dissipated in it. If that MOSFET is a standard MOSFET, and you're driving it with 5v, it isn't going to work very well. You need a logic level MOSFET, one that's designed to be driven with 5v. And monster heat sinks only work well up to a point. You can only get rid of so much heat so fast, they got limits too.
Why not post a schematic...we'll get a better idea of what you're up to. (on a side note, I haven't gotten over to the L298N datasheet yet).
lerameur
- 15th January 2007, 12:03
well eventually I would like to use 15v at 2 amps, so that h-bridge might to be ideal for now.
To follow your idea on using MOSfet, I found a web site talking about the IRF540, which is very similar to the one I have IRFZ44N., Except they use Pmos also, I guess I can use 4 Nmos and using an inverter instead of using 2 Nmos and 2 Pmos.
lerameur
- 15th January 2007, 17:33
what about driving one L298 per motor instead of two motors ?
will it be creating less heat ?
Archangel
- 15th January 2007, 20:39
I have a big ass heat sink, about 9 times he size of the chip.
Sounds good, how about some "B/A" bypass capacitors, or snubber diodes to protect those transistors, motors throw off some outrageous spikes which may well cause your bridge to get "Kentucky Fried".
what about driving one L298 per motor instead of two motors ?
will it be creating less heat ?
Always better, I think.
skimask
- 15th January 2007, 21:42
well eventually I would like to use 15v at 2 amps, so that h-bridge might to be ideal for now.
To follow your idea on using MOSfet, I found a web site talking about the IRF540, which is very similar to the one I have IRFZ44N., Except they use Pmos also, I guess I can use 4 Nmos and using an inverter instead of using 2 Nmos and 2 Pmos.
You got it, for the most part. In the end, you get 2 control lines, one for on/off, and one for direction. But, you will have to use 2 N's and 2 P's and an inverter (which you can also use a couple of small MOSFETs and a couple of resistors and make your own inverter from components rather than a 7404), N channel on top, P channel on bottom. Remember (in basic terms), N channel MOSFETs work by applying a ground to a circuit, P channel's apply power to the circuit.
And yes, some snubber caps and protection diodes, just in case. Motors are ugly in some ways...
lerameur
- 16th January 2007, 08:46
I put back the circuit together with one L298.
added caps, Its really hard to make them stick onto the motors, any thoughts?
Also it was not working at first, I realized that my Pic chip was not putting some pins at high. I changed the program so the pin output went from portC to portD and it worked. I reprogrammed the chip a few times, those couple of pins on PortC are not working no more. Can I revived them ? what happened..
skimask
- 16th January 2007, 17:38
I put back the circuit together with one L298.
added caps, Its really hard to make them stick onto the motors, any thoughts?
Also it was not working at first, I realized that my Pic chip was not putting some pins at high. I changed the program so the pin output went from portC to portD and it worked. I reprogrammed the chip a few times, those couple of pins on PortC are not working no more. Can I revived them ? what happened..
Post your circuit, otherwise it's hopeless...
lerameur
- 16th January 2007, 21:26
basically I am driving the h_bridge directly from microcontroller. Some one told me to use an opto coupler. BUt the output of the microcontroller is hooked up to the enable of the h-bridge, how can that fry my pins. I just fried my ccp pin..
Also, would it be better to use a seperate power supply for the controlelr and h-bridge?
skimask
- 16th January 2007, 21:37
basically I am driving the h_bridge directly from microcontroller. Some one told me to use an opto coupler. BUt the output of the microcontroller is hooked up to the enable of the h-bridge, how can that fry my pins. I just fried my ccp pin..
Also, would it be better to use a seperate power supply for the controlelr and h-bridge?
Like I said, post the circuit! We can hook you up with good info much quicker that way.
lerameur
- 16th January 2007, 21:49
ok, i need to draw it
any software has a 40 pin chip ?
keithdoxey
- 16th January 2007, 22:38
the output of the microcontroller is hooked up to the enable of the h-bridge, how can that fry my pins. I just fried my ccp pin..
Under normal circumstances, it shouldnt.
Having said that, you have already destroyed on H-Bridge which is being fed from your 12V supply. When that chip died it is possible that the 12v supply got fed back to your PIC.
One phone system that I used to work on had ULN2803 drivers for the relays. The phone system CPU was running on a 5v power supply but the relays were running off 47v. When systems were hit by lightning the power supply would normally die and sometimes the ULN2803s would be damaged. If you didnt find the damaged ones and replace them they would fail shortly after the system was powered up and stuff the 47v supply into the CPU killing it and the new PSU :(
I think you need to read up more on the basics of electronics as to date in this thread you have
Toasted an LCD
Cooked an H-Bridge
Fried a PIC
.... maybe a job in the catering trade would be more suitable based on the above :)
A picture is worth a thousand words so as Skimask suggested, a look at your schematic may give us the chance to help you resolve your problems. We have all been down the road of killing components, its how you build up experience. Expensive but it forces you to learn quickly !!!!
lerameur
- 16th January 2007, 23:27
as for the lCd that is entirely my fault,
but are you saying opto couplers are not necessary?
when should they be used. ?
i just read a few reports of similar problem that where resolved this way.
pic:
http://www3.sympatico.ca/lerameur/PDR_0141.jpg
skimask
- 17th January 2007, 05:30
as for the lCd that is entirely my fault,
but are you saying opto couplers are not necessary?
when should they be used. ?
i just read a few reports of similar problem that where resolved this way.
pic:
http://www3.sympatico.ca/lerameur/PDR_0141.jpg
Sorry guy...I can't make heads or tails of the picture in your last post.
lerameur
- 19th January 2007, 00:43
I decided i am going to put relays instead of an H-bridge.
I recently obtained some nice sensors from Taosinc.com. I wrote this program but it does not work. The datasheet is not complicated, but maybe I missed something. I seems that i need to put SI to high after the 129th clock. maybe I am not using the pulsin command right.
datasheet:
http://www.taosinc.com/images/product/document/TSL1401R-LF-E4.PDF
My program:
sensor var byte: counter var byte : pulse var byte
TRISB = %00000000
TRISA = %11111111
loop:
'clock input on RB0
'after 18 clock input at 1, count 111 clock cycles after the reset
pulse = 0
counting:
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 18 then goto continue
goto counting
continue:
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 130 then goto continue2
goto counting
continue2:
porb.0 = 1 'Si is now high
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 131 then goto continue3
goto continue2
continue3:
ADCON0.2 = 1 'Start Conversion
porb.0 = 0 'put the SI back to zero
ADCIN 0, sensor 'Read channel PORTA.0
pause 50
Lcdout $fe, 1 'Clear screen
Lcdout "Sensor: ", Dec sensor
Pause 200
goto loop
end
lerameur
- 25th January 2007, 22:18
I have bought the MCT6 chip (opto coupler)
I grounded pin 3 and 5
If I put a voltage a cross pin 4 should I get the same voltage across pin 6 ??
Archangel
- 25th January 2007, 22:24
I have bought the MCT6 chip (opto coupler)
I grounded pin 3 and 5
If I put a voltage a cross pin 4 should I get the same voltage across pin 6 ??
NO. here is a link to the data sheet'
http://www.fairchildsemi.com/ds/MC/MCT62.pdf
lerameur
- 25th January 2007, 22:55
I actually did the the circuit shown on page 5
http://www.ortodoxism.ro/datasheets/vishay/83645.pdf
still do not work.
Archangel
- 26th January 2007, 07:19
Ok leramuer,
Since I am too lazy to read 288 pages of this post over, I am not going to ASSUME anything. So here goes; Current flow, not to be mistaken with electron flow, current flows from positive to negative. The arrows in LEDs and Transistors indicate the current flow direction. Maybe you know all this, like I said, I will assume nothing. (1) Anyway, if you have a pic which outputs logic High, then you hook that port to pin 1 or pin 4 of the opto coupler, and pins 2,3 would hook to ground.(2) If ypur PIC outputs logic low then you would hook the port to pin 2 or 3, pins 1 and 4 would hook to the positive supply. now if your relay has one leg hooked to positive then the other leg would hook to pin 6, or 7.
If your relay has one leg hooked to ground, then the other end should hook to pin 5 or eight. As I said current flows in the direction the arrows point. It is that simple. CAUTION: Be sure to use current limiting resistors on the emitter side of the opto couplers as they only operate at 1.5v max 20ma so as not to fry them.
lerameur
- 26th January 2007, 08:46
ok I am getting the voltage now :)
I will be using this to ativate my h-bridge.
also, I am trying to solder a small capacitor (0.1uF) on the terminal of my motor. The solder does not want to stay eith on the pin of the case of the motor, do you have any trick here?
lerameur
- 26th January 2007, 08:51
also,
I dont usually use that and/or have seen this, but should we put resistors to ALL output pins of the microcontroller?
Archangel
- 27th January 2007, 00:07
also,
I dont usually use that and/or have seen this, but should we put resistors to ALL output pins of the microcontroller?
When I used the word pin, I meant the literal piece of metal sticking out of the part. I guess I should have said leads.
The opto coupler is made from 2 LEDs, 2 photo transistors. So in a word, Yes all the opto couplers LEDs should have series resistors.
As far as your PIC goes, I (personally) never leave pins floating out in space, I always tie them to Power or Ground as appropriate to their respective conditions.
I hope you found this to be of value.
JS
lerameur
- 27th January 2007, 02:37
so you are saying that you do put a resistor between the pin and anything that is connecet right, like an h-bridge or another microcontroller right
Archangel
- 28th January 2007, 08:21
so you are saying that you do put a resistor between the pin and anything that is connecet right, like an h-bridge or another microcontroller right
The pic outputs are matched to TTL levels, you can connect them directly to 5 volt logic devices without resistors.
A resistor is used anytime you need to limit the current to keep from smoking your PIC. look at the data sheet and see what the output ports can source or sink. What is the load you are putting on it? A 16f628A can sink or source 25 ma on each I/O pin and keep in the magic smoke. a resistor may be required in series to keep the current below the magic 25ma. In the case of these opto couplers a resistor is definately needed.
So looking at the DATA sheet from the opto coupler, the diode operates on 1.25 volts at 20ma. If you are using a 5 volt supply then the formula is :
5v - 1.25 v / .02 = 187.5 ohm so round up the closest say 200 ohm resistor and you are golden.
lerameur
- 29th January 2007, 02:43
Ok I am continuing my project.
I get a compiling error for my If then loop:
If I hide the two last line , then I dont get any error. But I need those lines. Any ideas?
if portb.0 = 1 then goto Option1
if portb.1 = 1 then goto Option2
if portb.2 = 1 then goto Option3
if portb.3 = 1 then goto stopping
else goto stopping
endif
error:
C:\PBP\MOTORG.BAS ERROR Line 62: Syntax error.
C:\PBP\MOTORG.BAS ERROR Line 63: ENDIF without a matching IF..THEN.
C:\PBP>
skimask
- 29th January 2007, 03:29
Ok I am continuing my project.
I get a compiling error for my If then loop:
If I hide the two last line , then I dont get any error. But I need those lines. Any ideas?
if portb.0 = 1 then goto Option1
if portb.1 = 1 then goto Option2
if portb.2 = 1 then goto Option3
if portb.3 = 1 then goto stopping
else goto stopping
endif
error:
C:\PBP\MOTORG.BAS ERROR Line 62: Syntax error.
C:\PBP\MOTORG.BAS ERROR Line 63: ENDIF without a matching IF..THEN.
C:\PBP>
if portb.3 = 1 then
goto stopping
else
goto stopping
endif
You can't have that first 'goto stopping' on the same line as the if/then if you're using an if/then/else type statement
lerameur
- 1st February 2007, 23:52
HI,
hope you are doing good.
I read a thread on this site concerning the 7805 overheating.
My 7805 is overheating even with a heat sink and I just have a LCD a pic chip and a RF receiving module. I tried the tricks they say but none is working.
I tried conencting the backlight directly to the 12v battery using a 150 IOhm resistor, or t o the 5V output of the 7805 with a 22 ohm resistor. Whils always keeping the LCD Vdd to the 5v of the 7805.
It heats op in every case ?
any ideas ?
Lcd 16 x2: UNIQ/eVision GC-1602I1
skimask
- 2nd February 2007, 00:14
HI,
hope you are doing good.
I read a thread on this site concerning the 7805 overheating.
My 7805 is overheating even with a heat sink and I just have a LCD a pic chip and a RF receiving module. I tried the tricks they say but none is working.
I tried conencting the backlight directly to the 12v battery using a 150 IOhm resistor, or t o the 5V output of the 7805 with a 22 ohm resistor. Whils always keeping the LCD Vdd to the 5v of the 7805.
It heats op in every case ?
any ideas ?
Lcd 16 x2: UNIQ/eVision GC-1602I1
What is your input voltage to the 7805? 12v?
What do you mean by 'overheating'? It's actually overheating and shutting down or just getting hot?
Put a meter across the 5v and ground lines at their input to the board. What does it read when using the resistance setting? What does it read when using the diode-check (continuity) setting?
This should help get it narrowed down...
lerameur
- 2nd February 2007, 00:32
It is 12v
I am getting .22amp It is getting very hot, but not shutting down.
Should I put a bigger heat sink or maybe two Lm7805 ?
skimask
- 2nd February 2007, 00:47
It is 12v
I am getting .22amp It is getting very hot, but not shutting down.
Should I put a bigger heat sink or maybe two Lm7805 ?
Here's a bit of math for ya...
12v input @ .22 amp = 2.64 watts total
5v output, drawing .22 amp = 1.1 watt.
(don't know if you're familiar with this stuff yet)
The regulator has to 'dump' 7v @ .22amp, which is 1.54 watts. That doesn't seem like a lot, but it's enough to make the 7805 hot, even if you've got a heat sink on it.
Do you have any heat sink compound between the 7805 and the heat sink face itself?
(oh...and .22amp for your configuration sounds about right)
Archangel
- 2nd February 2007, 01:15
HI,
hope you are doing good.
I read a thread on this site concerning the 7805 overheating.
My 7805 is overheating even with a heat sink and I just have a LCD a pic chip and a RF receiving module. I tried the tricks they say but none is working.
I tried conencting the backlight directly to the 12v battery using a 150 IOhm resistor, or t o the 5V output of the 7805 with a 22 ohm resistor. Whils always keeping the LCD Vdd to the 5v of the 7805.
It heats op in every case ?
any ideas ?
Lcd 16 x2: UNIQ/eVision GC-1602I1
Hi Ken,
Here are some figures for you to "SMOKE OVER" pun intended.
you need to add up the current draw of all of your outputs, and other loads and make sure you are not overloading your 7805 and your PIC. OR hook your DVM in series on the amp scale.
LED @ 4 volts at 45 ma hooked to 5 volt = 22 ohm
LED @ 4 volts at 20 ma hooked to 5 volt = 50 ohm
LED @ 5 volts at 20ma hooked to 12v =350 ohm
LED @ 5 volts at 40ma hooked to 12v = 140 ohm
LED @ 4 volts at 20 ma hooked to 12 volts = 400 ohms
LED @ 4 volts at 40 ma hooked to 12 volts = 200 ohms
the formula is still Rs = Vin - V led / I led. Where V in is input voltage, V led is led voltage and I led is LED current in ma.
Hope this is helpful.
JS
lerameur
- 2nd February 2007, 01:20
well because i still need all of these components. Its drawing way too much. 1.1 a out of 1amp max.
what about putting 2 Lm7805 in parallel?
Archangel
- 2nd February 2007, 01:35
well because i still need all of these components. Its drawing way too much.
what about putting 2 Lm7805 in parallel?
Honestly Ken,
I do not know if that works or not, That is a linear IC and I am not too sure how they will interact. I think a better solution would be to use a bigger regulator IC, or use 2 or more 7805s as seperate supplies using a common ground. Your pic can sink current from the secondary supply, and your display could also run from it. Note: check the data sheet for maximum current the pic can handle in total, so as not to exceed.
skimask
- 2nd February 2007, 01:41
well because i still need all of these components. Its drawing way too much. 1.1 a out of 1amp max.
what about putting 2 Lm7805 in parallel?
You just said you were drawing .22amp...
Which one is it? 1.1 a or .22 a ?
lerameur
- 2nd February 2007, 01:51
sorry 1.1watt
These babies can draw 1amp, why cant I draw more then .22 without being very hot ?
I dont see the wattage value on the spec sheet of this chip,
skimask
- 2nd February 2007, 02:15
sorry 1.1watt
These babies can draw 1amp, why cant I draw more then .22 without being very hot ?
I dont see the wattage value on the spec sheet of this chip,
There's a wattage value buried in the 7805 datasheet somewhere. And remember, your circuit is drawing 1.1 watt, but your regulator is dissipating 1.54watt, and you are drawing 2.64watts from your battery total.
The amount of temperature rise on the back of the 7805/heatsink/whatever, is directly related to the ability of that 'place' to dissipate heat.
If you've got something that just doesn't give up heat, it'll get hot...if it's very conductive, it'll stay cool.
So, with that being said, even 1 watt can feel very hot depending on what the heatsink is, if there is any heat conductive compound in between the 7805 and the heatsink, ambient temperature, etc.etc.
Think about it this way....take a 40 watt light bulb... It's hot right? All the way around it. It's also pretty big when compared to a 7805 with a heatsink. Now, take that same 40 watt bulb, shrink it 40 times, and apply 1/40th of the heat...sounds like it might be in that same ballpark. Obviously I don't know what the actual numbers would be, I'm generalizing quite a bit, I think it sounds reasonable.
And take another look at what I was saying earlier about how much power the regulator has to dissipate. Do you understand that much of it? (As in why the regulator dissipates 1.54watt when you power it with 12v and only draw .22amp from the regulator?) Remember, a linear regulator, such as a 7805, regulator by dumping extra voltage off as heat...that's the way they work (in simple terms anyways)...kinda like an infinetely variable power resistor that's always turning itself to keep the output voltage at a certain point.
lerameur
- 2nd February 2007, 02:39
well it dissipates 1.54watt because it can take 1watt , so 2.54 watt total from the battery. I guess I need this part: L78S05CV for now
skimask
- 2nd February 2007, 03:07
well it dissipates 1.54watt because it can take 1watt , so 2.54 watt total from the battery. I guess I need this part: L78S05CV for now
You could 'preregulate' the 12v input with either another regulator ( 12v -> 7809 -> 7805), maybe a few diodes in series, etc.etc. Knock the voltage down a bit before doing the final regulation to 5v. That'll cut down on your heat.
What package is this 7805 that you have right now? TO-92? TO-220?
lerameur
- 2nd February 2007, 03:24
it is TO-220,
by the way I once saw a sheet with all the packages types on the digi key web site, I cant seem to find it anymore. Would you have a similar sheet?
But instead of using 7809 and 7805, I think I will use a 2amp or maybe a 3 amp regulator it wont cost more.
k
skimask
- 2nd February 2007, 03:47
it is TO-220,
by the way I once saw a sheet with all the packages types on the digi key web site, I cant seem to find it anymore. Would you have a similar sheet?
But instead of using 7809 and 7805, I think I will use a 2amp or maybe a 3 amp regulator it wont cost more.
k
If you pull up a search on digikey for 'regulator', 'fixed', '5v', it should be able to show you pretty much all of the packages they have available.
Quite frankly, there's got to be something else going on. 1 watt on a TO-220 7805 isn't that much...and again, quite frankly, if the regulator isn't shutting down, I don't think it's getting too hot to worry about. The datasheet I've got for the TO-220 case shows a temp rise of 65C/watt without a heatseak (junction to air) and a max operating temp of +125C. That tells me that something just short of 2watts is safe. You're dumping 1.54watts, 1.54 x 65 = 100C. That's hot, but not really that HOT...especially if you've got a heat sink on it which will really drop that 65C/watt number to something more normal-ish.
In short, as long as it's not shutting down, you're good. If you're still worried about it, pull down a few datasheets and have a look at a thing called an 'external pass transistor'. Basically, you use the regulator to control the base of an external transistor which bypasses just enough juice to keep the regulator working and to basically do all the work for the regulator.
If not that, go ahead and parallel a couple of 7805's. Just keep in mind that 7805-A might be set at a slightly higher voltage than 7805-B, so you need to put a small value/high wattage series resistor inline with each output, or in bad cases, you'll have to isolate each regulator's output from each other with an inline diode.
Try it out...you won't hurt anything. At worst, they'll overheat and shut themselves off until they cool off...
Archangel
- 2nd February 2007, 05:37
Hi Ken,
I'm looking at your pictures and I have to ask, are you sure you have that regulator plugged in right, because if it's backwards it will still work (kinda) and will get hot. With the metal tab against the table and the leads pointing down, the terminals are numbered 123, 1 is input, 2 ground and 3 is output.
JS
websmith
- 2nd February 2007, 06:14
I come across many LCD's with incandescent globes inside them not LED's for the backlight, and designing the resistor for a 2.4V led will result in a whack of over-current. Just increase the series resistor to the backlight pins untill the display is only as bright as it really needs to be (try 150 ohms), this will certainly get you out of trouble with the regulator, and as they already advised you, feed it from the 'raw' side of the regulator not from the 5V regulated side. The backlight is completely isolated from the 5V rail of the LCD.
lerameur
- 2nd February 2007, 11:59
I actualy tried the 150 Ohm, and it gets hot just as fast.
NO the regulator is installed correctlt, with the 12v pin (1) on the outside, far away of the IC.
I cant play around too much with the circuit now, I will try it as is see, or get myself a 2amp regulator. Have to go to the store anyway to get an Lm331.
thanks
ken
lerameur
- 3rd February 2007, 21:55
HI
I am back working on my remote control code. I previously had two input for A/D. I needed to add another for my voltage checker. I used port B7 for the an6. or pin 13 on my pic16F88. When I dont put in the pic chi I read a voltage, say 0.8 volt. But when I put in the chip I do not read any voltage.
I tried the same circuit on a bread board and it do not do that. Could it be hardware or software. here is bit of the code:
just read below
lerameur
- 4th February 2007, 01:45
I finally found where the problem lies but dont know how to fix it. The led blinks but after 4-5 blinks, with the subroutine , it stops. If I dont put a subroutine it keeps on blinking. here is my program.
thanks
INCLUDE "modedefs.bas"
@ DEVICE PIC16F88 , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCON1 = %00100010 ' Set PORTA analog and RIGHT justify result, ADCON1 = %10000010 for 10 bit
ADCON0 = %10010010
TRISA = %11111111 ' Set PORTA to all input
TRISB = %10000000
input1 var byte
loop:
ADCIN 6, input1
pause 30
if input1 > 255 then
portb.3 =0
else
goto blinker
endif
goto loop
Blinker:
portb.3 =1 ' Turn on LED connected to PORTB.6
Pause 500 ' Delay for .5 seconds
portb.3 =0 ' Turn off LED connected to PORTB.4
Pause 500 ' Delay for .5 seconds
return
end
Archangel
- 4th February 2007, 04:33
I finally found where the problem lies but dont know how to fix it. The led blinks but after 4-5 blinks, with the subroutine , it stops. If I dont put a subroutine it keeps on blinking. here is my program.
thanks
INCLUDE "modedefs.bas"
@ DEVICE PIC16F88 , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCON1 = %00100010 ' Set PORTA analog and RIGHT justify result, ADCON1 = %10000010 for 10 bit
ADCON0 = %10010010
TRISA = %11111111 ' Set PORTA to all input
TRISB = %10000000
input1 var byte
loop:
ADCIN 6, input1
pause 30
if input1 > 255 then
portb.3 =0
else
goto blinker
endif
goto loop
Blinker:
portb.3 =1 ' Turn on LED connected to PORTB.6
Pause 500 ' Delay for .5 seconds
portb.3 =0 ' Turn off LED connected to PORTB.4
Pause 500 ' Delay for .5 seconds
return
end
Hi leramuer,
do you know the numerical value of input1 ?
Maybe the code is doing exactly what you asked it to do.
if input1 is greater than 255 shut off LED, if code is less then goto blinker,
maybe add in a debug and check value of input 1 as far as pic understands value.
edit: your comments in the blinker sub tripped me up, thought it was switching two different ports.
edit2: input var byte
if input > 255 then . . . 255 that's all a byte will hold . . . correct?
should not you select a number that is smaller?
lerameur
- 4th February 2007, 18:47
The comments are irrelevant for the ports in this case.
It blinks a few times then stps, thats why I dont understand. I will need to solder some wires and hook up a lcd to see what is happening.
ken
mister_e
- 4th February 2007, 18:54
Here we observe a nice stack UNDERflow example...
Change your GOTO Blinker to GOSUB Blinker
OR change your RETURN FOR A GOTO Loop
lerameur
- 4th February 2007, 19:08
yes thats, I knew it was software , could not get my finger on it. Thanks, it works.
mister_e
- 4th February 2007, 19:19
Good!
Something to remind: Always be careful when mixing Gosub, Goto and Return together
Joe S. ... i'm a bit disapointed ;)
Archangel
- 5th February 2007, 00:54
Joe S. ... i'm a bit disapointed ;)
what did I do?
Edit:
Ohhh I see, I missed his using a goto instead of gosub.
You know why I missed this, because I never tried to run his code in hardware, so I never copied it to PBP compiler. I got lazy. Sorry
mister_e
- 5th February 2007, 07:34
Oh i don't think you got lazy... after maybe over 100 reply in this 63 pages and 322 replies thread (feb 05, 2007).
It was more about kidding you a little bit ;)
Archangel
- 5th February 2007, 08:44
Oh i don't think you got lazy... after maybe over 100 reply in this 63 pages and 322 replies thread (feb 05, 2007).
It was more about kidding you a little bit ;)
I really got to get me some new computer glasses, my 15' LCD @ 1024 x 768 makes this forum really hard to see, the compiler has larger fonts and brighter text. Someday a 42" monitor. Seriously mister_e I think I don't miss too much considering the first thing I programmed was in july, and all my teachers are here.
mister_e
- 5th February 2007, 18:28
Yeah i know, seems you learn fast as well. Don't give up!
lerameur
- 6th February 2007, 00:12
HI,
how the heck do you disable portE.2 on a pic16F877a. I would like to use it as a serin pin. I would like to disable the parallel slave port, and make use of the serin command. The serin command works for portB fine.
thanks
skimask
- 6th February 2007, 00:22
HI,
how the heck do you disable portE.2 on a pic16F877a. I would like to use it as a serin pin. I would like to disable the parallel slave port, and make use of the serin command. The serin command works for portB fine.
thanks
What do you mean disable portE.2?
If you're talking about disabling the whole parallel slave port (driven using Port D), then set TRISE.4 = 0 (it's in the datasheet, Section 4.5, Page 50 I think).
P.S. Are we going for some sort of record on this thread? Because it's covered a LOT of subjects so far (wireless, A/D, I2C, math, etc.etc).
lerameur
- 6th February 2007, 00:27
well basically I use this command:
serin portB.2 = works
serin portE.2 = do not work
I set them both as input.
All my B ports are taken up already.
skimask
- 6th February 2007, 01:03
well basically I use this command:
serin portB.2 = works
serin portE.2 = do not work
I set them both as input.
All my B ports are taken up already.
It's not set up as an analog port is it?
Maybe you set TRISE as $FF instead of %00000111. If you did, bit 4 will change Port E into control for the PBP.
But, again, I'm probably pointing out the obvious to you...
Have you tried just setting the pin high and low and reading it and seeing what happens?
lerameur
- 6th February 2007, 02:25
Well here is the program that works:
but changing portb.2 to porte.2
it do not work.
INCLUDE "modedefs.bas"
@ DEVICE PIC16F877a , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
'HS 20mhz, watchdog off, powerup timer on, mclr external, brown out detect on, low volt program off , code protect off
DEFINE OSC 20 'use external 20mhz crystal
DEFINE LCD_DREG PORTD ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTC ' Set LCD Register Select port
DEFINE LCD_RSBIT 6 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTC ' Set LCD Enable port
DEFINE LCD_EBIT 7 ' Set LCD Enable bit ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
Pause 2000 ' Wait 2 second
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00111111
TRISC = %00010000
TRISD = %00000000
TRISE = %00000111
right var byte : left var byte
temp var word : counter var byte
rightold var word : leftold var word : speedright var byte : speedleft var byte
'************************************************* ***************************************
loop:
portb.7 =1
pause 100
portb.6 =1
pause 100
waitfor55:
serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55
waitforaa:
serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa
serin portb.2, n2400, rightold.LowBYTE : serin portb.2, n2400, rightold.HighBYTE
serin portb.2, n2400, leftold.LowBYTE : serin portb.2, n2400, leftold.HighBYTE
For counter=0 TO 7 'decoding
right.0[counter]=rightold.0[counter*2]
left.0[counter]=leftold.0[counter*2]
Next counter
Lcdout $fe, 1 'Clear screen
Lcdout "Left: ", Dec left
Lcdout $fe, $C0, "Right: ", Dec right
Pause 100
goto loop
end
skimask
- 6th February 2007, 02:58
Well here is the program that works:
but changing portb.2 to porte.2
it do not work.
Wow, that should work...
How about e.0 or e.1? Do they work?
lerameur
- 6th February 2007, 03:07
no does not work
I tried other B port and they work.
I tried the analog ports like porta.0 and does not work.
Should all the analog ports be used just for analog ?
k
mister_e
- 6th February 2007, 03:44
Should all the analog ports be used just for analog ?
Unless you disable the analog capability... yes
As far as i remind of this chip PORTE<2:0> have multiplex analog stuff on that you have to disable first
ADCON1=7
CMCON=7
those will help... but better if you refer to the datasheet to make sure of everything.
lerameur
- 6th February 2007, 03:47
that would include port e too?
I will need to use the analog port of portA later on too...
wouldn't that disable them ? Or do I need to find anothe rport for my serin command ?
I gues i have to play around with adcon (bit 0 to 3 )
mister_e
- 6th February 2007, 03:54
Yes indeed!
4.5 PORTE and TRISE Register
PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6
and RE2/CS/AN7) which are individually configurable
as inputs or outputs. These pins have Schmitt Trigger
input buffers.
The PORTE pins become the I/O control inputs for the
microprocessor port when bit PSPMODE (TRISE<4>) is
set. In this mode, the user must make certain that the
TRISE<2:0> bits are set and that the pins are configured
as digital inputs. Also, ensure that ADCON1 is configured
for digital I/O. In this mode, the input buffers are
TTL.
Register 4-1 shows the TRISE register which also
controls the Parallel Slave Port operation.
PORTE pins are multiplexed with analog inputs. When
selected for analog input, these pins will read as ‘0’s.
TRISE controls the direction of the RE pins, even when
they are being used as analog inputs. The user must
make sure to keep the pins configured as inputs when
using them as analog inputs.
Note: On a Power-on Reset, these pins are
configured as analog inputs and read as ‘0’.
;)
mister_e
- 6th February 2007, 04:03
I will need to use the analog port of portA later on too...
wouldn't that disable them ? Or do I need to find anothe rport for my serin command ?
I gues i have to play around with adcon (bit 0 to 3 )
Datasheet section 11, register 11-2, PDF page 130
Yes you got it !
lerameur
- 6th February 2007, 04:08
yes yes yes not so big, ADCON1=2 works good for me
thanks
k
skimask
- 6th February 2007, 04:25
Datasheet section 11, register 11-2, PDF page 130
Yes you got it !
DOH! I missed that too... jeez...somedays your on, somedays your off....
I'm a big Logic ZERO today... I think I'll go invert myself for a few hours...
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.