Pages: [1]   Go Down
Author Topic: Counter program  (Read 712 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to write a program that utilizes the following parts:
-arduino (of course)
-magnet switch (mechanical, thin metal disk)
-relay
-48vdc motor
-48vdc power supply (I will have a separate 5v power supply for the arduino)
-mechanical power switch
-magnet

The purpose of this program is this: when the motor is running, it's spinning a magnet which is attached to the shaft of the motor that goes by a magnet switch every rotation. Once 10 rotations are completed, I want the relay to power off the motor. Then I flip the power switch and the process starts all over again (this step I suppose doesn't even need to be programmed, the program should stop after 10 rotations). Rotations would be recognized using the on/off cycle of the magnet switch as the magnet on the motor shaft passes the magnet switch. This should be really simple to write except that I'm not an arduino/C# programmer. Thanks in advance for any assistance!
« Last Edit: May 03, 2013, 05:21:11 pm by uaware » Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3357
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have our permission.


... or what there a programming question there?
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm not an arduino/C# programmer
even someone as new as myself may be able to code that in C++ to do all that, at my stage it would be impossible without the hall switch or whatever kind of switch your counting with.

Code:
if (switch==10){
digitalWrite(motorRelay,LOW)}

but this sounds like it wouldnt be too hard to do, start with the examples and work your way through.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have our permission.


... or what there a programming question there?

I just simply wanted to know if you are always a dick or just act like one on internet forums?
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 84
Posts: 3414
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This will work if you reset the counter afterwards.
Quote
if (switch==10){
digitalWrite(motorRelay,LOW)}

But, you can also use the module operator ( % ), and have something like this.
Code:
if (switch % 10 == 0){
digitalWrite(motorRelay,LOW)}
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was looking for the same thing.  Every time the reed switch is closed you want to know that the motor went a revolution  http://arduino.cc/en/Tutorial/ButtonStateChange shows this functionality.

"The sketch below continually reads the button's state. It then compares the button's state to its state the last time through the main loop. If the current button state is different from the last button state and the current button state is high, then the button changed from off to on. The sketch then increments a button push counter."

I want to use this to operate a linear actuator for a satellite dish position.  I would like to be able to store the number of button pushes and change the position up or down by comparing the current position to the desired position.

In this way I want to track the sun for a parabolic solar hot water heater.
Logged

Pages: [1]   Go Up
Jump to: