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
Auto Light-Continiousely On?
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Auto Light-Continiousely On?
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.
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.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel