I'm beginning discovering a PIC world. Trying to build a voltmeter indicator, so it will turn LED on if input voltage drops lower than 3 Volts, and turn it back off it the voltage goes back. It sounds awefully simple, but I'm stuck for couple of day already. I'm using PIC12F683, in MicroCode Studio with PicBasicPro 2.47, and PICKit 2. I'd really appreciate if somebody could give me a code example how to make it work. Thanks in advance.
I'm beginning discovering a PIC world. Trying to build a voltmeter indicator, so it will turn LED on if input voltage drops lower than 3 Volts, and turn it back off it the voltage goes back. It sounds awefully simple, but I'm stuck for couple of day already. I'm using PIC12F683, in MicroCode Studio with PicBasicPro 2.47, and PICKit 2. I'd really appreciate if somebody could give me a code example how to make it work. Thanks in advance.
Here where I'm so far [see code below]. Conversion seems like working, but I can't make both LEDs go HIGH simultaniously! In other words when Vin somewhere between 86 and 170 both LEDs go into glow or blink. Is there a trick to make both of them go ON at the same time? Or am I doing something wrong?
Looking at your code, you should have both LEDs turned on. If you haven't then I would suspect you are overloading the pic pins and causing a RMW problem. Try placing higher value resistors in series with your LEDs, something like 1K. Alternatively, place a PauseUs(10) after each write to an LED.
Looking at your code, you should have both LEDs turned on. If you haven't then I would suspect you are overloading the pic pins and causing a RMW problem. Try placing higher value resistors in series with your LEDs, something like 1K. Alternatively, place a PauseUs(10) after each write to an LED.
They blink about 10 - 50 Hz. The problem is that they can't be ON both. As soon as I put HIGH GPIO.1, GPIO.1 goes LOW. Even with Pauses. Not sure how to use breakpoints. Will research it.
The 12F683 has a comparator module and CVRef, this should be a very simple program.
Comparator mode 3 looks promising, and CVRef can produce very close to 3V
When you get that working, in your first program remember that values 85,86,170 & 171 will do nothing.
You want to test your ranges more like:
if <85 ...
if >=85 AND <170 ...
if >=170 ...
I tried to use @ DEVICE PIC12F683, WDT_ON and @ DEVICE PIC12F683, WDT_OFF
Same effect. Not sure it's a correct way of configuring Watch Dog. I tried to program the chip and put on breadboard - it acts exactly like on simulator. Only one LED goes ON.
Yes. two 300 Ohm resistors between LED cathods and the ground.
matc said:
When you get that working, in your first program remember that values 85,86,170 & 171 will do nothing.
You want to test your ranges more like:
if <85 ...
if >=85 AND <170 ...
if >=170 ...
The numbers here are for the reference, I'm using a voltage divider potentiometer attached to the input. It changes the input voltage from 0V to 5V. Ideally PIC should turn one LED on at the beginning, both in the middle, and another one at the end of the potentiometer run.
The 12F683 has a comparator module and CVRef, this should be a very simple program.
Comparator mode 3 looks promising, and CVRef can produce very close to 3V
Can you post the circuit? That will help rather than all guessing.
EDIT: Download screen hunter (windows) or a program you can take a screen shot and post it. And you do have current limiting resistors on the LEDs like asked?