|
|
View previous topic :: View next topic |
Author |
Message |
newguy
Joined: 24 Jun 2004 Posts: 1911
|
|
Posted: Wed Mar 16, 2005 2:52 pm |
|
|
When the PIC's pins are configured as inputs, their input impedance is nearly "infinite". Therefore, if you place some charge on the input by connecting a 5V wire, it will take a long, long time to dissipate.
Add pulldowns to port d. Maybe 10k to ground or so. |
|
|
spudtheimpaler
Joined: 16 Mar 2005 Posts: 6 Location: Birmingham University
|
|
Posted: Wed Mar 16, 2005 3:05 pm |
|
|
newguy wrote: | When the PIC's pins are configured as inputs, their input impedance is nearly "infinite". Therefore, if you place some charge on the input by connecting a 5V wire, it will take a long, long time to dissipate.
Add pulldowns to port d. Maybe 10k to ground or so. |
Wow.... I'm at home now - I'm very tempted to go back to uni to try it. I scoured the datasheet for something to this effect but found nothing.... "schoolboy error" as it were.. If this works, and it seems it definately will... I will be joyful. So very joyful. I'm amazed and embarrassed that such a small thing has hindered such a huge project for so long.
Thank you all so very much for your help - The serious work can get underway now!
Again, thanks,
Mitch! |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
Re: eeerrrrrrrr...... |
Posted: Wed Mar 16, 2005 4:01 pm |
|
|
_Spudtheimpaler wrote: | I am assuming that when i take off the 5v from the input pins, it reads the pin as 0V... Is there some dissipation issues? does it take some time for the input voltage to leave the pin and are there resistor setups that will make this quicker? I've not been doing pic programming for all that long and whenever we have done it at uni before we are given a pre-fabricated board to test all our stuff on... This project was designed to "make us teach ourselves" and so this would be the infuriatingly simple kind of thing that i could miss... |
Never leave an input open. Exceptions are when there are pullup resistor internel to the chip (see port B). _________________ -Matt |
|
|
Guest
|
Do not use wires to make simulate the sensor input |
Posted: Wed Mar 16, 2005 8:38 pm |
|
|
As I said ealrier, I think if you are using a mechanical switch you will get bounce.... ! Wire are far worse... Do not use wires to make simulate the sensor input.
Do the correct thing. it's good to do it right at this stage, if you learn to be slopy then it will get you in the end when you donl;t need it to.
Make a sensor simlator, use another pic and debouce the heck out of a REAL set of small rocker switches and then have that pic output a CLEAN signal.... problem solved..
Good luck
hans w |
|
|
Guest
|
Re: Do not use wires to make simulate the sensor input |
Posted: Thu Mar 17, 2005 9:48 am |
|
|
Anonymous wrote: | As I said ealrier, I think if you are using a mechanical switch you will get bounce.... ! Wire are far worse... Do not use wires to make simulate the sensor input.
Do the correct thing. it's good to do it right at this stage, if you learn to be slopy then it will get you in the end when you donl;t need it to.
Make a sensor simlator, use another pic and debouce the heck out of a REAL set of small rocker switches and then have that pic output a CLEAN signal.... problem solved..
Good luck
hans w |
Definately sensible, thank you. The wire isn't just clipping the input though, i'm leaving it in there for seconds at a time. surely debounce wont matter for that sort of duration, surely it will loop reading the input port a thousand times in the space of seconds? |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1911
|
|
Posted: Thu Mar 17, 2005 10:22 am |
|
|
Yes, it will read it thousands of times/second, but that's not the point. Connecting a switch (i.e. simply pushing a button connected to the pic) can result in several "events", all very quickly. It feels like one push to you, but in fact it can be connecting/disconnecting several times, all in the space of a few milliseconds.
The pic is quick enough to read each of these bounces, and will react accordingly. Say that you have a button that will increment a value every time you push it. Sometimes it may only increment the variable once, but most of the time you'll find that one push (what feels like one push to you) will actually result in 2, 3 or 4 being added to the variable.
Taking a bare wire and connecting it to the pic by hand is WORSE. It will result in far more bounce than a regular switch will do. At the very least, please rig up some switches and hardwire them into the pic! |
|
|
Guest
|
Re: Do not use wires to make simulate the sensor input |
Posted: Thu Mar 17, 2005 11:25 am |
|
|
Anonymous wrote: | Anonymous wrote: | As I said ealrier, I think if you are using a mechanical switch you will get bounce.... ! Wire are far worse... Do not use wires to make simulate the sensor input.
Do the correct thing. it's good to do it right at this stage, if you learn to be slopy then it will get you in the end when you donl;t need it to.
Make a sensor simlator, use another pic and debouce the heck out of a REAL set of small rocker switches and then have that pic output a CLEAN signal.... problem solved..
Good luck
hans w |
Definately sensible, thank you. The wire isn't just clipping the input though, i'm leaving it in there for seconds at a time. surely debounce wont matter for that sort of duration, surely it will loop reading the input port a thousand times in the space of seconds? |
In prinicipal you are correct. However when you have a serious problem and are looking for a solution, it is good engineering practice to eliminate all the issue that can cause problems.
In this case touching a wire onto a pin is NOT good engineering by any standards. It will take about 1-2 hours to wire up a Vero board (yes I know what Vero board is ! difficult to find in the USA) run the sensor simulator with RC Osc. and you can have a reliable signal to test your design. Then fix the problem and move on.
You could even takle the simulator one step further and add a RS232 port to it, then you will have the sensor under control from a PC and can simulate all sorts of signals... there is not limit. Just do it right.
You said you had already spent 3 days on this issue 4 days ago !
Good luck..
hansw
BTW your test code is almost bomb proof, so IMHO you need to be looking elsewhere for the problem. |
|
|
Guest
|
Re: Do not use wires to make simulate the sensor input |
Posted: Thu Mar 17, 2005 11:52 am |
|
|
Anonymous wrote: | Anonymous wrote: | As I said ealrier, I think if you are using a mechanical switch you will get bounce.... ! Wire are far worse... Do not use wires to make simulate the sensor input.
Do the correct thing. it's good to do it right at this stage, if you learn to be slopy then it will get you in the end when you donl;t need it to.
Make a sensor simlator, use another pic and debouce the heck out of a REAL set of small rocker switches and then have that pic output a CLEAN signal.... problem solved..
Good luck
hans w |
Definately sensible, thank you. The wire isn't just clipping the input though, i'm leaving it in there for seconds at a time. surely debounce wont matter for that sort of duration, surely it will loop reading the input port a thousand times in the space of seconds? |
I think you are getting close to getting what you need. Be patient and make sure all you connections are correct and complete. Use you test equipment to make sure you are really getting what you think your getting. Use the debugger to make sure the registers and ports are set the way they are supposed to be set. |
|
|
_spudtheimpaler Guest
|
:( |
Posted: Thu Mar 17, 2005 11:58 am |
|
|
I've been working on it solidly since saturday :(
I understand there is best practice methods, and options like plugging into an rs232 (which i have virtually no experience in). But as Hans W points out, the code is virtually bomb proof. I found that adding the 10k resistors help a lot. i put them liberally on the input port and its a lot more stable. I still have voltage discharge problems on the input port, takes about half a second to discharge the voltage, but we are compensating for that in code.
I honestly don't believe bounce is the problem. Though i am doing some software checking on the input port. I think a combination of the discharge problem and another issue of input voltage. The sensors are putting out 3.71V and i thought that would be enough, but apparently its around about the threshold. I'm desperately hoping that 3.7 is enough, else i dont know, i'll have to try and mess around with ADC or comparitors or the like.
However, with simulated sensors the robot is now following as it should, so thank you very much! I shall keep the forum posted on progress ;)
Again, thanks,
Mitch |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Mar 17, 2005 1:40 pm |
|
|
Quote: | #use delay(clock=10000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT |
If you are truely using a 10MHz crystal or oscillator then you should probably be using HS not XT in your fuse statement.
Also add "NOLVP" unless you are using the low voltage programming mode.
If somebody already pointed this out, great, if not then make the change and test your code again. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
_spudtheimpaler Guest
|
|
Posted: Thu Mar 17, 2005 4:12 pm |
|
|
rwyoung wrote: | Quote: | #use delay(clock=10000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT |
If you are truely using a 10MHz crystal or oscillator then you should probably be using HS not XT in your fuse statement.
Also add "NOLVP" unless you are using the low voltage programming mode.
If somebody already pointed this out, great, if not then make the change and test your code again. |
Thank you. I found out about the NOLVP fuse when trying out different ports as inputs. I knew it existed, but didn't know it was on as default. As for the XT / HS issue, i will try that tomorrow morning when i go back. In the meantime I am going to scour the net as to what the differences are!
Thank you very much again
Mitch. |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Mar 17, 2005 5:24 pm |
|
|
Also, unless you have a good reason not to use the PowerUp timer, go ahead and use PUT instead of NOPUT. If you are using in-circuit serial programming, the power up timer is generally a good thing to have running. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
_spudtheimpaler Guest
|
|
Posted: Fri Mar 18, 2005 7:34 am |
|
|
rwyoung wrote: | Also, unless you have a good reason not to use the PowerUp timer, go ahead and use PUT instead of NOPUT. If you are using in-circuit serial programming, the power up timer is generally a good thing to have running. |
I'm not using in circuit serial programming. And again, I'm not entirely sure what the programming timer does at any rate. There is no time critical code in here, just a loop asking for input and then putting out an output. What does the power up timer do?
Cheers,
Mitch |
|
|
Ttelmah Guest
|
|
Posted: Fri Mar 18, 2005 7:40 am |
|
|
It is not a 'programming timer', but a 'power up timer'. It holds the chip in reset, for a tiny fraction of a second after power is applied. Starting immediately is fine, if your power rail rises very fast, but with the charging times of capacitors, and resistive connections, there can be a problem if the chip starts, and the supply rail has not fully established itself. The PUT, is a 'good thing', for 99% of installations, and really should default to 'on'. It is an exceptional circuit that needs to start as quickly as possible, and ha been designed to do this, that would not use the PUT.
Best Wishes |
|
|
WhistleBlower Guest
|
WARNING |
Posted: Mon Mar 21, 2005 1:08 pm |
|
|
Warning to spudtheimpaler... CHEATERS IN THE COMPETITION WILL BE OUTTED. WE HAVE YOUR NAME AND ARE GOING ABOVE YOUR HEAD TO CR. Attempts to gain external help for free WILL NOT BE TOLERATED. As per the specification document, you may gain assistance from other groups for an agreed fee. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|