Microcontroller Help

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hello all, first off I've been away from microcontrollers for about 10 years. The last one I played with was the original BS1 Basic Stamp (which I still have).

Heres my application:
I need to rotate a gearmotor with a paddle wheel about 45 degrees a specified number of times several times a day.

The motor control I think I understand and think I can use simple position feedback with a microswitch or opto to tell the MC when it's gone 45 degrees. What I'm not sure of is the event timing. Do I need a MC with a real Time Clock? How difficult would it be to use an lcd along with a few buttons to set the time and desired number of motor moves?
Thanks!
 
hi,
you can used encoder to detect the angel position and for speed you have to use pwm timing so you can do it slow or fast.
normally its not dificult but if you add more function will be a bit hard. you can used c-to write program. i dont know which mcu u are using may be you can try 16f877
 
Hi space2000, I should have specified this is going into an existing machine.
The motor is a regular 6v dc "hobby" type. The paddles of the wheel attached to the gearbox are set every 45 degrees. I was thinking of using a micro switch the paddles would hit as they went by to tell the MC how many paddles have gone by.
It seems the BS1 I have might work, but I'm concerned about timing. I'm looking at intervals of about 6 hours. I could use a PAUSE command a number of times to do this, but I get the impression accuracy might suffer after a few cycles.
If I get a BS2, I can connect a RTC to it for more accurate timing.
 
If it's running off mains power then you could put an input from the ac secondary of the transformer (use an AC plugpack/wallwart) and count waves. AC power, while not perfectly accurate cycle/cycle, has a very tightly controlled average frequency (lots of clocks depend on it :)). Shouldn't need much more than a zenner and a couple of resistors to condition the signal to suit the micro.

Cheers,
Duncan
 
Hmm, that's a really good idea.
Like this?
Forgot to add- this is through a 6.3v transformer of course.
 

Attachments

  • bs1 ac in.png
    bs1 ac in.png
    3.2 KB · Views: 110
I've drawn up a schematic of what I was thinking...


The 1K resistor R2 is there because the voltage on the zenner gets to -0.5v (1 diode drop) relative to ground and some chips don't like negative voltages past a certain current. Adjust value to suit...

Cheers,
Duncan
 

Attachments

  • clockinput.gif
    clockinput.gif
    3.6 KB · Views: 116
Looking at the diagram I can see there might be an issue, I'd also put a 10k from what's shown as the '-' pin on the transformer (it's ac obviously but you get the picture) and ground to ensure the transformer voltage doesn't float when the diodes aren't conducting.
Most PIC micros have hysteresis on their inputs and should have no trouble but you can also de-noise the signal in software by waiting for the pin to be high (or low) for an amount of time before acknowledging the change of input state (and incrementing your 'clock' counter).
 
Ok, so I've got the board connected with the motor and micro switch working.
I need some help with the code.
Since the BS1 can't count, I'm using a FOR...NEXT to set a number of loops controlled by the switch using the BUTTON instruction. It sort of works in that I can see the loop working but the BUTTON command is somehow resetting the FOR...NEXT each time it updates. I think its just a matter of getting things in the right order. Here's the code- Motor is on Pin 0 and the switch is on Pin 7:
Thanks!


SYMBOL btn = 0 ' FOR BUTTON

SYMBOL btnWrk = B4

SYMBOL reps = B2 ' FOR...NEXT loop counter

motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT


timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor

No_Press:
GOTO motor
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.