Microcontroller Help - diyAudio
Go Back   Home > Forums > Design & Build > Parts

Parts Where to get, and how to make the best bits. PCB's, caps, transformers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 24th August 2008, 09:22 PM   #1
imix500 is offline imix500  United States
diyAudio Member
 
imix500's Avatar
 
Join Date: Mar 2004
Location: Nashville, TN
Default Microcontroller Help

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!
  Reply With Quote
Old 25th August 2008, 12:54 AM   #2
diyAudio Member
 
Join Date: Mar 2008
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
  Reply With Quote
Old 25th August 2008, 02:57 AM   #3
imix500 is offline imix500  United States
diyAudio Member
 
imix500's Avatar
 
Join Date: Mar 2004
Location: Nashville, TN
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.
  Reply With Quote
Old 25th August 2008, 03:57 AM   #4
diyAudio Member
 
Join Date: Nov 2005
Location: Victoria
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
  Reply With Quote
Old 26th August 2008, 03:22 AM   #5
imix500 is offline imix500  United States
diyAudio Member
 
imix500's Avatar
 
Join Date: Mar 2004
Location: Nashville, TN
Hmm, that's a really good idea.
Like this?
Forgot to add- this is through a 6.3v transformer of course.
Attached Images
File Type: png bs1 ac in.png (3.2 KB, 93 views)
  Reply With Quote
Old 26th August 2008, 04:31 AM   #6
diyAudio Member
 
Join Date: Nov 2005
Location: Victoria
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
Attached Images
File Type: gif clockinput.gif (3.6 KB, 97 views)
  Reply With Quote
Old 27th August 2008, 02:11 AM   #7
imix500 is offline imix500  United States
diyAudio Member
 
imix500's Avatar
 
Join Date: Mar 2004
Location: Nashville, TN
Hi Duncan, that looks great. So my question is when the zener ceases to conduct every cycle, would the input pin be floating enough to cause random toggles? Should there be a resistor to hold the pin low during this time? Thanks!
  Reply With Quote
Old 27th August 2008, 06:42 AM   #8
diyAudio Member
 
Join Date: Nov 2005
Location: Victoria
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).
  Reply With Quote
Old 3rd September 2008, 03:49 AM   #9
imix500 is offline imix500  United States
diyAudio Member
 
imix500's Avatar
 
Join Date: Mar 2004
Location: Nashville, TN
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
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with microcontroller sss Everything Else 2 31st July 2008 05:30 PM
FLAC on microcontroller gene_klein Digital Source 4 1st December 2007 03:44 PM
microcontroller programming traf Digital Source 7 12th September 2007 01:49 PM
No microcontroller for PGA2310? louischia Chip Amps 12 4th March 2007 07:12 PM
Aleph P - microcontroller Klaus Pass Labs 23 7th November 2005 07:27 PM


New To Site? Need Help?

All times are GMT. The time now is 02:56 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2