Llama16
Newbie level 4
- Joined
- Aug 30, 2014
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 87
Hello everyone,
If this is the wrong forum: apologies, but I couldn't find a more appropriate one.
I did my bachelor in electrical engineering, but now master in a different engineering field. they once let us play with a PIC microchip, and only changing some variables in a premade template. Years later, I decided to start programming a PIC16F690 for a personal project. I've been busy for days trying to figure everything out. So pls don't shoot me when asking stupid questions. This is a 'from zero' beginner.
OBJECTIVE:
This might turn into a build thread later on. Thing is, I do motorcross and I would like to build a automatic startgate.
The working of the gate has to be the following: set up manually. Once on bike press a button on a remote, this triggers a 10 second red warning light on the startgate. Once the 10 seconds are up, a red light flickers for 5 seconds followed by a 1 sec buzzer and after that the gate gets dropped (with a 9V solenoid pushing (for 1 second) the release) between 3 and 6 seconds RANDOMLY after the flickering light.
I've already programmed the PIC with a pickit 2, it simulated perfectly. Oscillator is set correctly, registers should be correct,... Point is, on the computer it works. But this has to transfer to hardware .
I've used MPLAB with XC8 compiler and wrote it in C. A review is always welcome . **broken link removed** or attachment
I made the hardware scheme, with some small corrections by a friend. Here's how it looks like: See picture or attachement.
For the wireless part I have a cheap ebay 'garage controller'. Here is a list of all the used parts. I can only order from farnell. **broken link removed** or attachment
Today I've carefully made everything on a breadboard. And thus far I'm satisfied that it partially works. Here is what has to be solved, and really need your help with. I've been staring at it for hours and after this solo project, I'm ready for some outside help:
STATUS:
The input pin is kept low when the 9V battery is connected. After this the green 'on' light goes on, which it should. BUT the solenoide is also continuisly on (as soon as 9V is connected which draws alot of mA), which is not part of the plan. When setting the input to logic high by the 10k resistor (to avoid a floating state), the red light goes on as it should, it also flickers after 10 seconds for 5 seconds as it should. Also the buzzer goes off for 1 second as it should. Then (the random timing I suspect) a couple seconds later, the solenoid turns OFF and stays off. As you see this is ALMOST the reverse of the what the solenoid should do.
This was problem one. Then I have a second one: There is no way for it to do this for more than one cycle. I always have to replug the 9V battery to make it do this. This is what happens when I retrigger the input after 1 cycle: The leds work as they are supposed to, but the buzzer 'clicks' (like putting a DC on a speaker) AND the solenoid does nothing. This happens every retrigger I try after the first cycle. To avoid this I need to replug the 9V battery in, which is quite impractical.
PROGRESS1: I think I've figured out most of the problem. I was using a cheap 9V battery. I decided to use a second one and run the solenoid and buzzer on that one. This helped. Now the device can go through the cycle many times: the buzzer now always goes and the solenoid operates.
Still 2 problems persist: when hooking up the solenoid is still continuilsy on untill I've gone through the first cycle.
Problem 2: After a while the timers start to stretch out: The leds blink slower and the time seems prolonged on every timer?? this baffles me. Because I can't see a draining battery affect the internal oscillator of the PIC.
I also have a suspicion that the random timer isn't random but constant. Does the PIC support rand()?
PROGRESS2: when hooking up 18 volt, the leds and timers are faster. Now I really don't know anymore
---
I'm pulling my hairs out. I'm not the kind of guy to come for 'easy' advice, and like to try everything myself first, but this got me puzzeled and I can really use some advice.
Kind regards,
Dries Coppens
If this is the wrong forum: apologies, but I couldn't find a more appropriate one.
I did my bachelor in electrical engineering, but now master in a different engineering field. they once let us play with a PIC microchip, and only changing some variables in a premade template. Years later, I decided to start programming a PIC16F690 for a personal project. I've been busy for days trying to figure everything out. So pls don't shoot me when asking stupid questions. This is a 'from zero' beginner.
OBJECTIVE:
This might turn into a build thread later on. Thing is, I do motorcross and I would like to build a automatic startgate.
The working of the gate has to be the following: set up manually. Once on bike press a button on a remote, this triggers a 10 second red warning light on the startgate. Once the 10 seconds are up, a red light flickers for 5 seconds followed by a 1 sec buzzer and after that the gate gets dropped (with a 9V solenoid pushing (for 1 second) the release) between 3 and 6 seconds RANDOMLY after the flickering light.
I've already programmed the PIC with a pickit 2, it simulated perfectly. Oscillator is set correctly, registers should be correct,... Point is, on the computer it works. But this has to transfer to hardware .
I've used MPLAB with XC8 compiler and wrote it in C. A review is always welcome . **broken link removed** or attachment
I made the hardware scheme, with some small corrections by a friend. Here's how it looks like: See picture or attachement.
For the wireless part I have a cheap ebay 'garage controller'. Here is a list of all the used parts. I can only order from farnell. **broken link removed** or attachment
Today I've carefully made everything on a breadboard. And thus far I'm satisfied that it partially works. Here is what has to be solved, and really need your help with. I've been staring at it for hours and after this solo project, I'm ready for some outside help:
STATUS:
The input pin is kept low when the 9V battery is connected. After this the green 'on' light goes on, which it should. BUT the solenoide is also continuisly on (as soon as 9V is connected which draws alot of mA), which is not part of the plan. When setting the input to logic high by the 10k resistor (to avoid a floating state), the red light goes on as it should, it also flickers after 10 seconds for 5 seconds as it should. Also the buzzer goes off for 1 second as it should. Then (the random timing I suspect) a couple seconds later, the solenoid turns OFF and stays off. As you see this is ALMOST the reverse of the what the solenoid should do.
This was problem one. Then I have a second one: There is no way for it to do this for more than one cycle. I always have to replug the 9V battery to make it do this. This is what happens when I retrigger the input after 1 cycle: The leds work as they are supposed to, but the buzzer 'clicks' (like putting a DC on a speaker) AND the solenoid does nothing. This happens every retrigger I try after the first cycle. To avoid this I need to replug the 9V battery in, which is quite impractical.
PROGRESS1: I think I've figured out most of the problem. I was using a cheap 9V battery. I decided to use a second one and run the solenoid and buzzer on that one. This helped. Now the device can go through the cycle many times: the buzzer now always goes and the solenoid operates.
Still 2 problems persist: when hooking up the solenoid is still continuilsy on untill I've gone through the first cycle.
Problem 2: After a while the timers start to stretch out: The leds blink slower and the time seems prolonged on every timer?? this baffles me. Because I can't see a draining battery affect the internal oscillator of the PIC.
I also have a suspicion that the random timer isn't random but constant. Does the PIC support rand()?
PROGRESS2: when hooking up 18 volt, the leds and timers are faster. Now I really don't know anymore
---
I'm pulling my hairs out. I'm not the kind of guy to come for 'easy' advice, and like to try everything myself first, but this got me puzzeled and I can really use some advice.
Kind regards,
Dries Coppens