DQ542MA Stepper Driver

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Gavo
Posts: 14
http://meble-kuchenne.info.pl
Joined: Thu Dec 24, 2020 7:23 pm
Been thanked: 1 time

DQ542MA Stepper Driver

Post by Gavo »

Hi All,

I am using a DQ542MA Stepper driver with a NEMA 23 Motor, I have the attached Arduino program below working and tried to convert the Arduino to flow code using a LED as a component. I can't seen to get the FC to run at all, any advice on how to get it running in FC?

Many Thanks,

Regards,

Gavin

int dirpin = 11;
int steppin = 10;

void setup() {
Serial.begin(9600);

pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}
void loop()
{

int i;

digitalWrite(dirpin, LOW); // Set the direction.
delay(100);

Serial.println(">>");
for (i = 0; i<10000; i++) // Iterate for 4000 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(200); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.

digitalWrite(dirpin, HIGH); // Change direction.
delay(100);

Serial.println("<<");
for (i = 0; i<10000; i++) // Iterate for 4000 microsteps
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(200); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.

}
Attachments
DQ542MA.fcfx
(11.22 KiB) Downloaded 161 times

LeighM
Valued Contributor
Posts: 394
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 69 times
Been thanked: 208 times

Re: DQ542MA Stepper Driver

Post by LeighM »

I would try it a little slower first.
Try a 1mS delay rather than 200uS
You should then also be able to see the direction output change with a DVM
(aka LED flash test - just to check the Uno is running ok)
Unless you have an oscilloscope or logic analyser?

Gavo
Posts: 14
Joined: Thu Dec 24, 2020 7:23 pm
Been thanked: 1 time

Re: DQ542MA Stepper Driver

Post by Gavo »

Hi Leigh,

Thanks for the response, please see attached Scope Plots

SDS00006 is the FC and SDS00007 is from the Arduino Code - looks like the FC is inverted to that of the Arduino Code?


Regards,

Gavin
Attachments
SDS00007.png
SDS00007.png (48.86 KiB) Viewed 4461 times
SDS00006.png
SDS00006.png (39.89 KiB) Viewed 4461 times

Gavo
Posts: 14
Joined: Thu Dec 24, 2020 7:23 pm
Been thanked: 1 time

Re: DQ542MA Stepper Driver

Post by Gavo »

Hi Leigh,

I changed the Polarity of the LED , it still has no effect on the motor,

Regards,

Gavin

LeighM
Valued Contributor
Posts: 394
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 69 times
Been thanked: 208 times

Re: DQ542MA Stepper Driver

Post by LeighM »

Did you change the delay to 1mS?
Using the oscilloscope, can you see the 1mS pulses out of the Uno? And the direction change?
If so, the Flowcode project is working as it should. If not, then we need to get that working first.

If the stepping pulses are seen...
What is the motor doing? Any sound?
Does the driver board have an enable signal input that needs setting/driving from the Uno?

Gavo
Posts: 14
Joined: Thu Dec 24, 2020 7:23 pm
Been thanked: 1 time

Re: DQ542MA Stepper Driver

Post by Gavo »

Hi Leigh,

I do see it change, only issue the amplitude of the FC is way smaller to that is the Arduino code.

The motor is doing nothing, no sound neither.

I have also connected the enabled but I see it should be connected to GND, I have changed the FC to suite, please see attached.

Regards,

Gavin
Attachments
DQ542MA.fcfx
(12.68 KiB) Downloaded 160 times

LeighM
Valued Contributor
Posts: 394
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 69 times
Been thanked: 208 times

Re: DQ542MA Stepper Driver

Post by LeighM »

Maybe try a small delay between Step::Off and Step:0n

User avatar
p.erasmus
Valued Contributor
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: DQ542MA Stepper Driver

Post by p.erasmus »

Hi

I have placed some delay as Leigh has mentioned in your flowchart to test the PIN operations and Voltage levels,This is all working fine ,
I am thinking you should carefully think and code the stepping sequence ,

On my Chinese UNO (Clone) your modified FC chart produced this wave form

Test1.jpg
Test1.jpg (57.41 KiB) Viewed 4397 times
This is your modified FC Chart (this is in no way correct it only test the HW and for stepping the motor you need to redo the cart :D

DQ542MA.rar
(52.18 KiB) Downloaded 147 times
Hope this helps you in any way
Regards Peter - QME Electronics

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: DQ542MA Stepper Driver

Post by chipfryer27 »

Hi

Further to Peter's answer above, I too can confirm an output train of pulses using his code.

You mentioned earlier that your motor isn't doing anything so things to check if you haven't already, and sorry if this is stating the obvious.

It isn't clear your control connections. The controller has optocoupler inputs so one side is connected to either + or - with the other side controlled by the Uno. So depending on connection a High on a pin could switch an optocoupler On if using common 0v. Alternatively if using a common 5v then a pin going High would switch it Off. From what I read you are going High to create a rising edge so I assume that is turning the optocoupler On.

The following assumes common 0v for the optocouplers so that for example your Step On command activates the PUL optocoupler.

That means the following connections and as your Uno R3 is a 5v device and can handle 20mA on pins it is quite easy. The controller OptoCouplers control inputs would be :-

PUL+ = B2 (Step)
PUL- = 0v
DIR+ = B3 (Dir)
DIR- = 0v
ENBL+ = B4 (Enable)
ENBL- = 0v
(common these 0v's and connect to Uno 0v too)

I'm under the impression, but could be wrong that to enable the device you don't actually want the enable optocoupler active (as doing so disables the unit) so you should have your code output a 0 on ENBL+ (Turn Off B4), or for testing purposes don't connect it at all. That does seem counter productive. Disable to Enable, and has caught me out before.

Next is to check your DIP switches. From your post you are microstepping with 4000 steps per revolution so

SW5 = On
SW6 = Off
SW7 = On
SW8 = Off

SW4 can be ignored for testing as it sets the standstill current. Personally I'd put it in Off position thereby halving current.

SW1 - SW3 set the current for your motor and as I don't know what you are using I cannot suggest, but set these to give the closest peak value to that of your motor. If you have set these too low then you may face issues (all Off gives highest ~4A and all On gives lowest ~1A).

Next check your DC Motor Supply (DC+ / DC-) which can be anything from 18vDC to 50vDC. The remaining connections are for your motor coils and again I can't help as I don't know your motor but it should clearly state A+ / A- / B+ / B-

I see in your original chart that you haven't initialised any of the ports (set them to a known state). Generally speaking you should do so at the beginning (and also for any variables in use) as you cannot guarantee which state they will be in prior to issuing a command. Perhaps include some code early on to set them to a known state?

Typically but not always, these controllers like a duty cycle of around 20 - 25% to achieve optimum performance. Your original post didn't have any at all as your PUL (Step) toggled immediately (went Off and back to On immediately) which is why a delay was suggested by Leigh.

In Peter's post he has added a delay to your loop turning Step Off, delaying 1mS then turning it On, delaying 1mS before repeating until exit. This provides a pulse with a 50% Duty Cycle (On for 50% of the time and Off for 50% of the time). This will work fine, but if you are running the controller at it's highest limit you may need to adjust delays to give on for ~25% and off for ~75%.

You will probably find documentation somewhere that will give a maximum input frequency (e.g. 20KHz) meaning it can accept 20,000 pulses per second. That would equate to one pulse every 50uS and that pulse would be On for 12.5uS and Off for 37.5uS for a 25% Duty Cycle).

When testing I would keep things slow initially to help with any faultfinding.

I've incorporated these changes into your chart, increased some delays and I again state I'm assuming you have the the optocouplers in a common 0v configuration. The chart should rotate your motor at just under 4RPM with a 25% duty cycle before reversing direction and repeating.

Let us know how you get on.

Regards
Attachments
DQ542MA_Test.fcfx
(13.56 KiB) Downloaded 159 times

Post Reply