Arduino and the NewBee

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Foozer, bad luck about the Arduino.
In a class there is a constructor and a destructor If you can master classes, you will be a programming wizard...

Arduino's are cheap enough, have a spare (UNO and a Mega) and ordered a couple more just in case. Just don't use those Wall-Wart power gizmos :)


Will have to look up the terms and get at least a rudimentary understanding - As it is or at least as I understand so far can place say #define red1 52, 52 becomes defined as red1 [Red Led] which allows led.blink(pinNumber, rate) to be written out in the sketch as led.blink(red1, 200) - - Much Much Easier - - Kinda like how St Thomas Aquinas wrote . . Listed objections than replies but takes two readings to follow it - First straight through for flavor than back to objection 1 with reply 1 for the digest.

It's not that the exclusion of library's from sketching is bad, but rather of a deficient good for all things of a deficient good are still good none-the-less. But to include the exclusion makes the sketch bad absolute.

Query - have noticed that when switching enable on/off on say a 200 step motor, the driver configured for eighth stepping will cause the motor to jog as if the poles now energized are aligning themselves to what a step position at a 200 rate would be rather than the in-between position the motor may be at -

Ok time to put more of this together and ratchet up a library for the stepper directions - Then you say - will have a neater page to work with to get what must needs be done . .
 
I'm no library wizard, but the newborn ones do indeed work.
Note to self 'It's tab key in Keyword.txt not space bar . .'

Check switches in void setup() and move table to what I'll call a Home Position for now - - -

// Begin Table Position Check
led.on(ledStart); // pin number
Stepper.Run(enableX); // Turn On Stepper
if(digitalRead(sw2)==HIGH && digitalRead(sw3)==HIGH);
delay(50);
{
do
{
Stepper.CCW(stepX, dirX, 800); //stepPin, dirPin, rate microseconds
}
while (digitalRead(sw2) == HIGH); // While sw2 is Open
}
if(digitalRead(sw2)==LOW && digitalRead(sw3)==HIGH);
delay(50);
{
Stepper.Stop(enableX); // enablePin Turn off Stepper
led.off(ledStart); // ledPin
led.on(ledOff); // ledPin
}
// End Table Position Check

Usage of, does indeed clean up the sketch
 
Ya! Poor mans stepper acceleration - Only took a few hours before I realized I could not reset the timer1 counter while in the runY_down() function - Like really? the button controller spits out 255 when no button is pressed, use that to reset . . .

if (nesButtonData == 255)timer1 = 1200; // first line void loop

void runY_down()
{
timer1- -;
if (digitalRead(enableY) == HIGH)Led.blink(ledGreen, timer);
// Off Do Nothing - Blink Led
// if(digitalRead(enableY) == LOW) // On
if (timer1 < 1200 && timer1 > 1100)timer2 = 800; // timer2 - microseconds
else if (timer1 < 1099 && timer1 > 1000)timer2 = 700;
else if (timer1 < 999 && timer1 > 900)timer2 = 600;
else if (timer1 < 899 && timer1 > 800)timer2 = 500;
else if (timer1 < 799 && timer1 > 600)timer2 = 400;
Stepper.CW(stepY, dirY, timer2);
}
 
Rather than take the long way around the fence, better to just cut a hole in it and pass through. Shortened up the language for bringing the motor up to speed . . .

// timer1 begins at 2000, counts down to 400 and then is set at 400
// timer1 is reset in getNesButtonDada to 2000 when NesButton is released . . .
// Count down timer1 and Accelerate stepper speed from slow to high
timer1 = timer1 - 2; // Adjustable Acceleration rate
if (timer1 <= 400)timer1 = 400; // 400 is top speed for the test platform motor
Stepper.CW(stepY, dirY, timer1);
 
Before Arduino, I made a stepper driver using an Atmel ATmega, programmed it in Atmel studio, and made a dual h bridge out of mosfets. I could do full stepping and half stepping. The switch statement is the way to go. Your if statements needed else if and else. Switch is easier, more elegant.
 
And about debouncing, the engineers over at Collins screwed the pooch on the FMS in the CRJ I fly. Half the time I have to delete stuff because one of the other inputs doubled or tripled pressed. An ACARS message may look like this: TTHANKSS FOR THEE WEATTHERR..

I would think a software denounce using a timer, say 80 ms goes by before another input is recognized.
 
. . . Switch is easier, more elegant.

Am liking Switch - Case, can fiddle with a single case and not break the others. Finally got the section I wanted to do what I wanted it to do. To take a inputed Y axis total depth of cut e.g. 0.250, divide that into number of increments needed to go @ 0.010 cut per pass, run X axis back and forth, increment, x axis back and forth, increment . . then stop when done . .
{
// Begin Function - Make sure table is at Home Position
if (digitalRead(sw2) == HIGH && digitalRead(sw3) == HIGH)
{
do
{
Stepper.CCW(stepX, dirX, 800); //step, dir, rate microseconds
}
while (digitalRead(sw2) == HIGH);
}
for (; x < cycleY; x = x + 1)
if (cycleY == y)y = 0;
if (z == 2)z = 0;

// Fist Move Y axis Jog Amount
delay(500); // Delay Half Second
{
for (int jog = 0; jog < 480; jog++) // @ 3:1 ratio Jog Y 0.010 inch
Stepper.CW(stepY, dirY, 800);
delay(500);
}
// Then Move table to sw3 ... Cut Material
if (digitalRead(sw2) == LOW); // Check Position Switch
delay(50);
{
do
{
Stepper.CW(stepX, dirX, 800); //step, dir, rate microseconds
}
while (digitalRead(sw3) == HIGH); // While sw3 is Open
z = z + 1; // Set Z counter to 1
// Then Move table back to sw2
if (digitalRead(sw3) == LOW); // Check Position Switch
delay(50);
{
do
{
Stepper.CCW(stepX, dirX, 800); //step, dir, rate microseconds
}
while (digitalRead(sw2) == HIGH); // While sw2 is Open
z = z + 1; // Set Z counter plus 1 sets z now to 2
if (x >= cycleY)y = y + 1;
// y is Increment cycle counter, counts up to meet cycle y variable
if (y == cycleY)Stepper.off(); // If counters equal turn off steppers
x = 1;
}
}
}
// End Function

Now to mount the full scale stuff in a box, hook up the Y Axis stepper, redo the position switches and try it out . . .

Still have a check list to solve - Can button press increment the total depth of cut, but need to add in a means to decrease should I over shoot the number . . . Right now press button, increases by 1, hold button down and will increase by 1 every qtr second

And if I don't write out an instruction sheet soon, I'll forget the how and why what the heck I made to be used . . .
 
Now I'm just getting anal with the testing model, time to take the bucket of parts and get things going . .
test2_zpslwh3jees.jpg




Course if it begins to look like my work bench, I may be at it for a while . .

test3_zpslwv0hbxp.jpg
 
Working it from the 'Cigar Box' to well, a bigger box. Red band for X, yellow band for Y - For bells and whistles wanted to have an external means to set a Y axis total cut distance. Worked it out to change the variable with button(s) push to increment and decrement. But first go round and ran out of available pin on the standard UNO - - Why use more buttons, use the Keypad she said - -

Huh? Ah Yes I see dear, keypad also spits outs a different number when two buttons are pressed, e.g 250 is Select + A, 249 is Select + B. So can use button A for one thing and 'Select + A for another thing.

Now that frees up some pins and so far it all fits on a standard UNO - Back to wires - Figure if I start out trying to keep them neat - well . . .

_60_zpsogthaoff.jpg
 
What kind of scope are you using there. I'm using an arduino and a Gshield v5 on mine

image.jpg
 
What kind of scope are you using there. I'm using an arduino and a Gshield v5 on mine

Haven't progressed to the 'black box' called G-Code yet. Was only a few weeks ago that I started looking into arduino coding. Once I get comfortable with the X-Y then it'll be time to get the X-Y to work together to work a circle . . .

See, was making some T-Nuts and got tired of hand cranking - Hooked up a windshield wiper motor - worked fine but couldn't hand crank - Then to a stepper with a simple push button controller - could hand crank but kept forgetting which button was what direction - Then to Arduino with a Y axis stepper - Then to . . . And I already made the T-Nuts I wanted to make . .

So the 20x4 LCD came today - Time for a little bell and whistle inclusion . . . I try not to think about it too much least I shake my head and go "Really!"
 
I have used arduinos for other projects for a couple of years. The Gshield is almost plug and play. You run a program on the arduino nod then the Gshield handles all the motor movements. I just got it Monday and got it talking buy Tuesday. Relatively painless. This is the type stuff I normally use arduinos for.

image.jpg
 
Ha. Not that much free time. With three boys my free time is limited. It comes in spurts. Lol.
 
One day I will figure out why it flips my pics too!??
 
Btw the electronics area of my shop is way worse. Lol

image.jpg
 
One day I will figure out why it flips my pics too!??

I'm going to guess you take them with an iPhone/iPad? Apple will let you flip your device but still retains an arbitrary 'top' which it encodes into the picture. It'll be right way up all the time on an Apple device but on a pc it depends which way up you took it.

If it's some other camera I have no idea...
 
int, float, string - - Oh-My - All I wanted was a bell and whistle, the LCD to display in inch what the step jog amount is e.g 16 steps=0.001" - - Int nope, won't do decimal math - Float - took an hour or so to fi8nd out it chops it off 2 places after decimal -- String? Oh-Boy - - don't know, but it works

printjogX = String((stepsX / 16) * .001, 3);
lcd.print(printjogX);
// steps increment-decrement by 16 and/or 160 dependent upon button combo

I have an intake manifold to put on the car, however, with this Arduino diversion what is a day job might take until Xmas . . .
 

Latest posts

Back
Top