Welcome! Log In Create A New Profile

Advanced

Arduino Firmware Help

Posted by Michael.Duffin 
Arduino Firmware Help
July 14, 2009 03:00PM
Hi,

I am using Chris Meahans new reprap firmware (uses timer1 for stepping and has ramping),

Could anyone tell me how and where I would invert the Step signal, My drivers step Low not high. Not bothered about Dir as I can invert no problems.

Any help would be great.

Thanks.

Michael.
VDX
Re: Arduino Firmware Help
July 14, 2009 04:57PM
Hi Michael,

which version do you have?

In all my versions in the function "do_step(byte step_pin)" you can invert the stepping polarity by exchanging HIGH v. LOW (a.v.v.) in the lines "digitalWrite(step_pin, HIGH)" and "digitalWrite(step_pin, LOW)"

Viktor
Re: Arduino Firmware Help
July 14, 2009 05:02PM
Not the one your using, Does your verision support ramping & lookahead?

I have attached the one i'm using

Thanks

Edited 1 time(s). Last edit at 07/14/2009 05:05PM by Michael.Duffin.
Attachments:
open | download - reprap_new_firmware.zip (20.1 KB)
Re: Arduino Firmware Help
July 15, 2009 12:02AM
I took a quick look at the code and you want to look for occurances of step_bitmask[ in stepper_control.pde.

This is quite complicated code, maybe you would want to go for a quick hardware solution?

[exmrclean.blogspot.com]
VDX
Re: Arduino Firmware Help
July 15, 2009 03:53AM
Hi Michael,

... ok, got it - the older versions are also partially coded by Chris, but without accel.

So you have either to invert the init and canceling polarity in the software or solve it with hardware by adding an inverter-IC ...

Viktor
Re: Arduino Firmware Help
July 15, 2009 06:46AM
Cheers Freds & VDX

I can (myself) invert the step signals quite easily electronicly! However where is the fun in that! I have built a small CNC controller which consists of a Pocket PC (the host) and an Arduino Nano running Chris's firmware.

I use this same device to control both Reprap machine and a CNC router (reprap steps high Mill steps low) so I would really like to be able to simply invert it in the firmware. I have scanned through the code and can see where the stepping is happening but have no/little understanding of the step_bitmask and how it changes the outputs from high to low.

I feel it shouldn't be that difficult but as I am very new to both C and the Arduino IDE I'm pretty stuck.

VDX you said "invert the init and canceling polarity in the software" how and where would this be done?? Sorry to be a pain but without getting someone over at the Arduino forum to go though every last bit of code I have no where else to turn.

Thanks Again.

Michael.

Edited 1 time(s). Last edit at 07/15/2009 08:26AM by Michael.Duffin.
VDX
Re: Arduino Firmware Help
July 15, 2009 08:34AM
Hi Michael,

the running software only inverts the step-pins on every occurance, so you have to initialise the pins at startup to HIGH and when stopping set them to HIGH again instaed of LOW as now.

I don't have the arduino-IDE here, so out from memory: - somewhere in the end of the stepper-controller.pde you have to set the pins to LOW by something like "step_pin[] &= ~step[X]" or such for every axis XYZ.

Here the "&=" is a logical AND with the "~" value, so this would set the appropriate pin to zero or LOW. Look in the manual for boolean operators on single bits how it's best to set it instead of deleting.

When at home i'll look in detail ...

Viktor

Edited 1 time(s). Last edit at 07/15/2009 08:35AM by VDX.
Re: Arduino Firmware Help
July 15, 2009 09:36AM
Cheers VDX,

I had a look, think I found that part of the code.

// Write the step pins low again - the time taken for the
// preceding calculations will be more than enough to
// ensure that there has been a long enough high pulse
*step_output_reg[X_AXIS] &= ~step_bitmask[X_AXIS];
*step_output_reg[Y_AXIS] &= ~step_bitmask[Y_AXIS];
*step_output_reg[Z_AXIS] &= ~step_bitmask[Z_AXIS];


I tried a few days back removing the ~ this stops it stepping after the first step. After initial startup the Step signal is still high. After trying to step it goes low and stays there!

Thanks for your help so far and if you wouldn't mind having a more detailed look when you get home that would be Fab!!

Cheers.
VDX
Re: Arduino Firmware Help
July 15, 2009 09:50AM
Hi Michael,

... maybe it's something like "*step_output_reg[X_AXIS] |= step_bitmask[X_AXIS];" where instead of "AND" with an inverted value it should be "OR" with the bitset for staying HIGH.

Look in the handling of bit-values and especially the operators "&" (AND), "|" (OR) and "~" (maybe INVERT) ...

Viktor
Re: Arduino Firmware Help
July 15, 2009 10:10AM
Have tried just about every possible combination of opperator added and removed the invert tilda still no joy, Don't really know what the hell i'm doing to be quite honest!!!

Michael.
VDX
Re: Arduino Firmware Help
July 15, 2009 05:17PM
Hi Michael,

... as i understand, you have to exchange the "set HIGH" and "set LOW" lines.

With "*step_output_reg[...] |= step_bitmask[...];" you set the corresponding step-pin to HIGH
and with "*step_output_reg[...] &= ~step_bitmask[...];" to LOW.

So you have to search every occurance of this expression and exchange "... |= ..." with "... &= ~..." and vice versa.

For the first initialisation you have to set the lines to HIGH at the beginning - e.g. "*step_output_reg[X_AXIS] |= step_bitmask[X_AXIS];" (and Y,Z too) at the end of "init_steppers()"

Viktor
Sorry, only registered users may post in this forum.

Click here to login