Notifications
Clear all

Large Stepper Code does not work

119 Posts
5 Users
10 Likes
8,162 Views
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@ralphxyz 

Looking closely at both images shows that your last circuit connects both PUL- and DIR- to GND, but Bill's circuit ties DIR- to pin6 and PUL- to pin7 of the Arduino.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Yes, they are not the same. I am not a programmer, I have tried adding Bill's code 

to the working code, seems simple, but so far have failed.

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@ralphxyz 

I doubt that you'd be able to use Bill's code with a setup that's not wired the same. I don't know anything about the stepper driver, so I don't understand the purpose of + and - terminals for direction and pulse, but I can tell you that unless Arduino pins 6 and 7 are always tied LOW in Bill's code (for a start, I didn't look for other changes) that his sketch won't work with your circuit wiring.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

With the motor slowly turning if I push the DIR button the motor stops.

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@ralphxyz 

Bill's code is using the driver in common anode mode and the example you're using is common cathode mode, so neither of the sketches is usable on the other's wiring.

What specific motor driver are you using ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

I am using a Microstep Driver, I "think" the difference is in the control chip

Mine uses a clone and will do 32 microsteps I believe Bills driver uses the 

original control and will do upto 16 microsteps.

Other than that I do not know of any differences.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1641
 

Hi @will and @ralphxyz ,

I think you may be making some progress, but the path looks rather twisty. I hope you won't mind if I discuss it a little .. well maybe a lot ... 🙄 

---------------

You say "The only way the motor works is with a common ground!"

This is concerning, not because I dispute your observation, but because the motor controller should have opto-couplers to eliminate the need for a common ground for some very good reasons...

Imagine your Arduino is an expensive and delicate measuring/control system whose task is send control signals to a high power motor. The electrical power to the motor will tend to have spikes and transients, and its 'ground' power line is likely to be very 'noisy'. If these spikes are coupled to the delicate control system, they will probably 'confuse' the measurements and so on, causing the motor control to be eratic or fail. This is common situation in industry, and elsewhere, so to minimise the risk, the control system and the motor/motor controller are usually powered from different sources, and the only 'communication' between the two is in the form of pulses of light - there is no electrial connection.

To be strictly accurate, your motor controller unit includes the electrical break by means of three 'optoisolators', each of which are essentially two independent electrical components in the same plastic package, but electrically isolated from each other. One component is connected to one of ENA+ & -, Pulse +/-, or Dir + & -; the other component to the motor controller electronics which supplies power to the motor.

The pins ENA+ & -, Pulse +/-, or Dir + & - should all be electrically isolated from all of the other motor controller connections, including its power ground. (A 'professional' quality unit would be safety tested to a few thousand volts to ensure it met expectations.)

So whilst I hope there are no safety issues with your more modest setup, your observation of needing a common ground seems to contradict my expectations. Unfortunately, it is not easy for me to see why this is the case.

-----------------------------

The circuit that posted earlier from Bill does not have a common ground, yet I think it should work. (Yes, I have been proved wrong before ....! But Bill is more reliable ... 😀 )

---------

You also said ' "Yes, Arduino GRN to 24V GRN, a "Common" ground. ' - which was the definition I understood you to mean, using Bill's circuit for the rest of the wiring.

Note: Bill connected the +5V line to all of the opto isolator LED diode anodes, such that each LED will be powered and 'light up' when the cathode is taken to (near) 0V by the respective controller pin.

This (infra red) 'light' will illuminate the phototransistor within the opto isolator, causing the "effective resistance" between the collector and emitter to fall to a low value, compared to the high "effective resistance" in the absence of illumination. This change of "resistance" is detected by the motor driver circuit, and interpreted appropriately as a control signal. (The LED and phototransistor are electrically isolated from each other.)

Other than the flow of current through the optoisolator LEDs, there should be no current flow between the Arduino and the motor controller, and hence no need for a 'common' ground line.

--------------

More recently you have shown the Makerguides circuit. This is significantly different in that each of the opto-isolator LED anode is connected to a Arduino control pin, and all of the LED optoisolator cathodes are connected to Arduino Ground/0V line. In this case, the respective LED will produce light when the Arduino pin is high (5V), with current flowing through the LED and back to the Arduino Ground. Obviously you must connect the Arduno ground to the optoisolator "-" inputs to complete the circuit just described.

However, you should not need to connect the Arduino ground to the 'general' power ground of the motor controller.

--------

These two alternative wiring schemes swap the 'sense' of control levels from the Arduino ...

i.e. the first connection scheme 'illuminates' the LED when the Arduino control pin is low (~0V) and is 'dark' when the output is high (~5V).

The second connection scheme 'illuminates' the LED when the control pin is 'high' (~5V) and is 'dark' when the output is low (~0V).

Thus the software 'sense' of the three pins is 'reversed' between the two schemes. In other respects, they are essentially the same.

-------------

There is another subtle difference between the two schemes. Logic output pins from some chips are able to sink a larger current to 0V needed for the 'Low' state, than they can source to create a 5V level for the 'high' state, and hence the first connection scheme is more commonly adopted. In the case of the Uno, the difference is probably quite small, and you are unlikely to notice a difference.

---------------

The Makercircuit does not connect the enable ... which I think is fine, as it appears to be more of a "Disable" input, which disables the motor drive when the LED is illuminated. Unless you can find a use for 'disable' ... such as an emergency override/halt ... then I suspect you can leave it disconnected.

----------------

Simplistically, I would expect your test program to be able to change the speed by changing the delay times in the loop, and the direction by changing the DirPin output to Low. I presume you have tested this and found it behaved as expected.

That being the case, you are in a position to wire your pot and switch into the Arduino, and add some code to 'read' these controls and change the output signals appropriately. I should have expected Bill's program to work, providing you have the same wiring as his. 

-- if I was in your position, I think I would migrate from your circuit to his in small steps, changing your program as you change the wiring, and checking it still works at each stage.

I note the "=" signs in the listing in Bill's blog look like "-" signs on my screen ... I presume you spotted that?

Good luck ... you are probably nearly there! Dave


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 
Posted by: @davee FYI @ralphxyz ,

[snipt]

---------------

The Makercircuit does not connect the enable ... which I think is fine, as it appears to be more of a "Disable" input, which disables the motor drive when the LED is illuminated. Unless you can find a use for 'disable' ... such as an emergency override/halt ... then I suspect you can leave it disconnected.

----------------

Thanks, Dave

Another reason for using the enable/disable is to free up the motors after the task is complete. Often, they don't need to be powered to keep them in place and they can be disabled in order to manually move the system to a new starting position or whatever.

Disabling them should also reduce the power required and allow the steppers and drivers to cool off.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

The makerguide program (and wiring) works I can vary the sped of the stepper up and down.

Bill's program only works when I have a common ground and the motor moves very slowly.

With Bill's program the Speed POT does nothing and DIR switch only kills the motor rotation.

Yes there is a optical coupler on board.

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1641
 

Hi @will

  You make a good point about using enable in the right circumstances. I hadn't considered that possibility. For applications I imagined, switching the whole system off at the wall was easier when I was bored with it 🤨 

As for when it is 'paused', I imagined a system that had to 'calibrate its start position at power up, and wasn't sure if disabling and then re-enabling the drive risked it moving a 'cog' either way, thereby upsetting the calibration. Perhaps this not an issue? I haven't got a system to test it on.

Hi @ralphxyz,

   Sorry, I don't understand why you have a problem with Bill's circuit and software ... it should be almost the same as yours, albeit plus a pot and switch.So a mixture of your test program, adjusted for any pin changes, and Bill's circuit should work, albeit with direction sense reversed.

With your circuit, I assume:

  • only ground from the Arduino going to the motor/motor controller board is that shown to Dir- and Pul- (plus Ena-, if you wired it in). i.e. it should not need a link beween Arduino ground and motor controller ground.

 

  • Resistance measurement from Dir- (or Pul- or Ena-) to Motor controller ground, shows 'infinite' resistance. Disconnect the links to the Arduino before doing this test to avoid the possibility of an external loop back to the mains supply.)

I still suspect a vital piece of evidence is hiding. As I mentioned previously, I think I would 'migrate' from your system to Bill's in stages, testing as you go.

Good luck to you both. Dave


   
Inst-Tech reacted
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

I have tried to migrate the code but as I have said I am not a programmer.

Thanks Will! It will be interesting to see what happens.

Ralph


   
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

@davee  You make a great point @davee.. Grounding issues can be very complex, especially when instrumentation is power by external AC power.. In industrial applications, we used separate grounding systems, one for AC and building grounds, and the DC Instrumentation is on a Triad grid grounding system.

When we have instrumentation that had an analog (ie 4-20 mA) output from a instrument that was powered from an AC source, we used Opto-coupled isolator modules to interface the Instruments output (4-20mA) to the DCS, PLC, or DAQ computer systems. In this case, it looks like if the Motor controller boards inputs are Opto isolated( Dir- or Pul- or Ena-) then their should be no ground connection between the Arduino and the motor controller board..That could very well induce a ground loop..

Just my two cents worth..

Regards,

LouisR

LouisR


   
DaveE reacted
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Will, 1st try your code does not work.

Thank you for the effort, it certainly gives me something to work off.

I will play around to see if I can find the the problem.

I'll try doing some serialwrites to see if I can debug.

Ralph

This post was modified 2 years ago by Ralphxyz

   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Had a problem with my wiring, surprise surprise. The motor is working but the Pot and Dir switch have no effect.

Ralph


   
ReplyQuote
Page 2 / 8