Page 1 of 1

Auto Light-Continiousely On?

Posted: Fri Jul 25, 2014 12:03 pm
by JDR04
Hope somebody can help me with this.

With kind help from medelec35 I have constructed a program that will detect when light levels fall below a set threshold and a LED will turn on.

I have made a few small changes and added some stuff myself. The simulation works 100% and am happy with it.

However...... when I come to construct the circuit there seems to be a problem with the very beginning of the program. The intention is when power is applied, an LED and a BUZZER will come on twice and then the program moves on. I have connected the LED and the buzzer but the buzzer just turns on continuisely. The LED seems to be off.

Once I can get the first stage to work then I'll move onto connecting up the threshold pot and the phototransistor.


I've attached the flowchart and would appreciate somebodies help and advice on this. Thanks a lot John

Re: Auto Light-Continiousely On?

Posted: Fri Jul 25, 2014 1:06 pm
by Benj
Hello,

Sounds like a great project and a good way to improve your skills.

In the initial loop there needs to be a delay after the PortA = 0 output icon to allow the off period to be "seen/heard" by the user. Otherwise your almost instantly back to switching the output on again.

The reason that your LED is not lighting could be the fact that you have no configuration settings for your device and the A5 pin will automatically be tied to the oscillator circuit. If you go into the Build -> Project options -> General Options Tab then tick the Configure the chip tick box and click the configure chip button.

The Settings you probably need are going to be like this.
config.jpg
config.jpg (93.74 KiB) Viewed 3473 times
Internal RC no clock specifies the internal oscillator and that the osc pins A4 & 5 can be used as I/O.
The other key setting I changed is the Watchdog setting which is an advanced feature and periodically resets the device to ensure it is running the code correctly. Unless you specifically want this I would advise to always disable.

Click OK and next you need to assign the correct clock speed for your project so the delay icons work as expected.

By default the internal oscillator will fire up at 4MHz on your 12F683 so set the clock speed setting to 4000000.

Click OK again and now hopefully your program should run as intended on the hardware.

Re: Auto Light-Continiousely On?

Posted: Fri Jul 25, 2014 11:58 pm
by JDR04
Thanks Benj, will give it a bash tomorrow.

Appreciate the help.......John