pinout/wiring for A4988?

335 views
Skip to first unread message

Sean Dungan

unread,
Dec 2, 2019, 3:56:27 PM12/2/19
to Raspberry Pi Film Capture
Greetings,

Apologies in advance for the following electronics-illiterate questions! Can anyone provide me with a wiring diagram/ pin instructions for A4988 driver and Dominique's software? Do the pin #'s in the code refer to the actual pin #, or the GPIO#?  I originally had it wired to Joe's diagram, which was more or less working but motor turned very slowly. Now we are attempting to change the wiring to match Dominique's code, but I don't know which pins on the A4988 are Trigger and Pulse. Also, the code has Pulse going to (I think) GPIO23, which is where MS2 is wired according to Joe's diagram. Help??

John Hoppa

unread,
Dec 3, 2019, 3:57:16 PM12/3/19
to Raspberry Pi Film Capture
Sean

Here's how I wired the A4988 driver to run with Dominique's code.

VMOT > Motor Pwr Supply +
GND > Motor Pwr Supply -
2B,2A,1A,1B > Motor Coils
VDD > 3.3 volts (pins 1 or 9)
GND > Header Ground (pins 9, 14, or 20)

DIR > GPIO 18
STEP > GPIO 23
SLEEP > GPIO 17

Jumper between A4988 SLEEP and RESET

Trigger circuit > GPIO 24 and unused ground (pins 9, 14, or 20)

The A4988 driver worked fine for "Motor Control" and "Capture on Trigger".  However on "Capture on Frame" after the motor stopped and tried to restart the driver limited the current (at max stetting) causing a pulsing phenomenon that produced multiple images of the same frame.  I'm not sure as to whether it was a motor or driver problem.  I'm now using a TB600 driver with no problem.  Dominique's code seems to provide smoother control than what I experienced with Joe's.

Hope this info helps.

Sean Dungan

unread,
Dec 3, 2019, 5:52:46 PM12/3/19
to Raspberry Pi Film Capture
Thanks for this info John.

You mention a jumper between SLEEP and RESET- is RESET unconnected to Pi? Also, are MS1 and MS2 unused?


John Hoppa

unread,
Dec 4, 2019, 7:01:20 AM12/4/19
to Raspberry Pi Film Capture
No other connections to Pi.  RESET is indirectly connected through SLEEP.

Sean Dungan

unread,
Dec 4, 2019, 7:12:28 PM12/4/19
to Raspberry Pi Film Capture
Thanks again John. I think I might have fried my driver, as I can't get the motor to move. It does make an unpleasant whining sound though. Also, the Preview function doesn't seem to be working... not sure if the camera is connecting. 

Dominique Galland

unread,
Dec 5, 2019, 5:39:30 AM12/5/19
to Raspberry Pi Film Capture
If you buy a new driver I recommend a TB600
The cabling of the motor with the high voltage is well separated from the PI (can save your PI !) , the inputs are isolated by optical couplers and if necessary the micro stepping is controlled by switches which is more convenient.
Dominique

John Hoppa

unread,
Dec 5, 2019, 6:19:27 AM12/5/19
to Raspberry Pi Film Capture
Sean

I highly recommend following Dominique's recommendation.  It's working well in my project.  If you do decide to use the TB600 please know that "These controllers required a 5v control pulse , but the pi only has a 3.3v gpio , connecting the (PUL+ DIR+ ENA+) to 5v and trying to use gpio to control it will result in damage to your pi, because the gpio is not 5v tolerant ( any input over 4v will damage gpio/pi )".

Additional circuitry (2N2222 transistors and 1k resistors) are required.  All the details are given in this url:


John

Dominique Galland

unread,
Dec 5, 2019, 11:10:22 AM12/5/19
to Raspberry Pi Film Capture
Personally I wired directly the three pins PUL, DIR, ENA on the PI without any damage during hours of operation.
For the PI they are output pins with a 3,3V signal, if it is enough to trigger the driver I do not see why there would be a risk for the PI ?
Obviously this problem would be different for input pins.
Dominique

John Hoppa

unread,
Dec 6, 2019, 6:58:11 AM12/6/19
to Raspberry Pi Film Capture
Dominique

You are correct.  In my haste to keep my project going with the installation of the TB6600 driver I recalled seeing the post in the Pi forum when I was working on an Arduino project.  Without complete understanding of how it was being used I incorporated the use of the transistors.  Thank you for the correction.

Sean

I apologize for my misleading information.

John

Sean Dungan

unread,
Dec 6, 2019, 11:02:54 AM12/6/19
to Raspberry Pi Film Capture
Thanks John and Dominique. I've ordered a TB600 and will wire it directly. Then we can see if the driver was the problem... Thanks!




Sean Dungan

unread,
Dec 7, 2019, 8:10:55 PM12/7/19
to Raspberry Pi Film Capture
I've installed the TB600, but still have no response from the stepper. Red light on the TB600 is on.

The ENA+ DIR+ and PUL+ are sharing 5v pin #4 on the Pi.

ENA- goes to GPIO 17
DIR- goes to GPIO 18
PUL- goes to GPIO 23

None of the CamDialog buttons seem to be doing anything, though commands are being listed in the Pi terminal. Also if power is on, the stepper sometimes makes a noise until CamDialog is launched.

In TelecineApplication I'm getting the message "Object arrays cannot be loaded when allow_pickle=false"

Sometimes I can get a preview image to appear if I select Preview and then hit Capture. Though it seems to have crashed just now. This is what the terminal says:

TelecineApplication Errors.png




Dominique Galland

unread,
Dec 8, 2019, 1:02:20 PM12/8/19
to Raspberry Pi Film Capture
Sean,

Let's take things in order.

1. There has been a change in an update of Python, the allow_pickel argument is now mandatory. So, you must add allow_pickel = True in all np.load statements for example:
 np.load ("local.npz", allow_pickel = True)
In TelecineApplication.py and also on the PI in Controller.py
I have to postpone it in an upcoming update

2. To see if the client-server communication works, you have to look at the output window on the PC and on the PI.
When you activate a button in the interface you must see a command on the PI terminal.
Your log probably indicates a clent-server communication error. You also have to look on what happens on the PI, probably the application has exited.
In case of error send me both outputs.

3. For the camera first try the simplest "Open" (camera version should be displayed) then "Shot".
Only after you can try Preview (Capture without motor) and again after On Frame or On Trigger (Capture with motor)

4. For the motor first try the simplest "On" engine is powered (noise + resists movement) then "Forward One"  "Forward" and only after "On trigger"

Good luck,

Dominique

Sean Dungan

unread,
Dec 9, 2019, 7:26:52 PM12/9/19
to Raspberry Pi Film Capture
Hi, thanks for these suggestions.

I've amended the code and no longer get the pickle error. Thanks!

However, there is still no response from the motor. I've double-checked the wiring. The TB600 is wired directly to the Pi. It's getting 12v from the power supply. No power detected by multimeter at the + and - terminals to the motor- I'm assuming that this is because the driver is not telling it to move? I've ruled out the motor itself as a problem by testing an identical spare.

There are no error messages in the Pi terminal, just commands listed as the GUI buttons are pressed.

When I turn the camera on, and then hit shot, I get a larger preview window with an image from the camera, and then TelecineApplication crashes, with the following messages in the terminal:

TCApp_Error_2019-12-09.png


John Hoppa

unread,
Dec 10, 2019, 7:50:26 AM12/10/19
to Raspberry Pi Film Capture
Your error message looks similar to a problem with the camera not responding to various camera commands.  My message was the following:

Stop
Traceback (most recent call last):
  File "Controller.py", line 402, in <module>
    request = commandSock.receiveObject()
  File "../Common/MessageSocket.py", line 71, in receiveObject
    s = self.receiveString()
  File "../Common/MessageSocket.py", line 59, in receiveString
    return self.receiveMsg().decode()
AttributeError: 'NoneType' object has no attribute 'decode'

The problem was with segmentation faults.   I don't know the exact failure mode but the fix for me was to replace QT5 on a Linux PC running Lubuntu.  I believe that you're using a mac and may be experiencing a network communications problem rather than a motor or driver problem.  Based on information which I found on-line that solved a similar problem, I compiled from source and installed  Qt5, SIP, and PyQt5.  In hindsight maybe an installation from source of  PyQt5 was all that was needed instead of the pip install.  Network communication is now flawless.


Sean Dungan

unread,
Dec 10, 2019, 9:46:30 PM12/10/19
to Raspberry Pi Film Capture
Actually we started on a Mac but have switched to Windows 10 on a PC. I've consulted with my IT consultant (my brother) and he thinks we should run Linux on the PC in order to do exactly what you are doing. Then we'll install Qt5 SIP and PyQt5 and see if that helps...

Sean Dungan

unread,
Dec 10, 2019, 9:56:12 PM12/10/19
to Raspberry Pi Film Capture
Hi Dominique,

After "On", the motor can be turned by hand- does not seem to be getting power. 

I've set the dip switches to match yours, as I think we have the same kind of motor nema 17?

Do you mean reduce the size of preview window by changing the code? Or is this Hres and Vres in the CamDialog? I do get an image before the application crashes, but the preview window is gigantic and only shows a corner of the image. 

Pi outputs:

Pin#1- 3.3v to reed switch
Pin#2- 5v to light relay
Pin#3/GPIO2- to light relay
Pin#4- 5v to ENA+, DIR+, PUL+ on TB600
Pin#8/GPIO14- to reed switch and red LED
Pin#11/GPIO17- to TB600 ENA-
Pin#12/GPIO18- to TB600 DIR-
Pin#16/GPIO23- to TB600 PUL-
Pin#39- GND to light relay

Sean Dungan

unread,
Dec 27, 2019, 7:32:40 PM12/27/19
to Raspberry Pi Film Capture
Hi John,

In order to match what you have done, we are preparing to switch the PC to Linux, and I wanted to ask you a few questions if you have a moment:

Which Linux distribution are you using, and did you build Python from source or use one supplied with Linux?

Which QT5, SIP, and PyQt5 modules did you install from source, and which versions of each?

On the Pi, did you also build Python and modules from source? 

Thanks very much!!


John Hoppa

unread,
Dec 29, 2019, 12:43:29 PM12/29/19
to Raspberry Pi Film Capture
Hi Sean,
Please pardon me for the delayed response but post Christmas family activities have precluded much time at the computer.

Linux Distribution = Lubuntu (Ubuntu16.04.6 LTS) (16.04 only because I had the image handy 18.04 should work just as well)

Python 3.7 = PIP Installed.  I run the TelecineApplication.py application in a Python 3.7 virtual enviornment with the following:

~/yart-master/GUIControl$ pip3 list
Package               Version
--------------------- --------
cycler                0.10.0 
kiwisolver            1.1.0  
matplotlib            3.1.1  
numpy                 1.17.3 
opencv-contrib-python 4.1.1.26
pip                   19.3.1 
pkg-resources         0.0.0  
pyparsing             2.4.2  
python-dateutil       2.8.0  
setuptools            41.6.0 
six                   1.12.0 
wheel                 0.33.6

Qt5 = 5.7
SIP = 4.18.1
PyQt5 = 5.7

I used these version only because when I was searching for segmentation fault fixes a post that was made about 2.5 years ago fixed a similar problem to the one I was having.  Newer versions may in fact work also.

I would highly recommend that before yow switch to linux you consider setting up and running GUIControl in a Python 3.7 virtual environment.  Your issues may be caused by conflicts in Python versions.

John

Alain Doublet

unread,
Feb 21, 2020, 11:00:17 AM2/21/20
to Raspberry Pi Film Capture
Hi John,
Many thanks for your answer, and for the help from Dominique,

 Client side, I use Ubuntu 18.04 LTS in a virtual environment dedicated for this project.
With Python3.7, the next packages (see the image attached) were installed by pip..

When TelecineApplication is running, the connection to Raspberry server, the opening of picamera and the motor tests are working fine...But then, the commands "shot" or "capture" provokes a "segmentation fault"...
Server side, the terminal is frozen on a "Command:0x0"...
Have you any idea to diagnose further this problem.
Btw, THANKS for your help !
Et voilà ...
Alain

pip_list.png


Reply all
Reply to author
Forward
0 new messages