How to upload firmware

184 views
Skip to first unread message

Shai Schechter

unread,
Dec 22, 2020, 6:49:12 PM12/22/20
to Smart Stepper
Hi all,

Trying to upload the firmware to a self-made board using all the same components with a J-link EDU. I was wondering if anyone knows if a J-link EDU version will work? Following this tutorial here: https://learn.adafruit.com/proper-step-debugging-atsamd21-arduino-zero-m0/restoring-bootloader

However, it seems that the J-Link EDU version I got isn't producing 3.3V when measured across vRef and GND. I've also un-populated R1 and R2 at the regulator per the schematic but now the voltage is 0 for 3.3v traces. Whereas before when I did populate it according to the schematic, the voltage was about 1.5V if I recall. So I suppose I need to double check the regulator resistor values myself per the chip's spec sheet. I assume the open source schematic is outdated?

I've tested directly feeding 3.3V and measuring and it's fine, no shorts. However, double clicking the reset button doesn't light up the red LED. Is it supposed to light up even if there's no boot loader? Any help appreciated as I'm trying to upload boot loader.

I think I installed all the necessary drivers. Using latest MacOS with Arduino IDE. I also followed the MIsfittech firmware upload guide here and installed all the necessary files per on that page.

Shai

unread,
Dec 22, 2020, 6:50:59 PM12/22/20
to Smart Stepper

misfittech

unread,
Dec 23, 2020, 7:03:20 AM12/23/20
to Smart Stepper
The Vref is measurement of the voltage on the board, it is not designed to power the board. Hence you need to power the board with a different power supply while programming. 

The first thing you must do is program the bootloader on the board, this is the code that makes the LED blink. The source code for the Bootloader used on the smartsteppers is on github and is copied from Adafruit. 
The binary is checked in (samd21_sam_ba.hex) you can use the JFlashLite.exe which is part of the Segger JLinkEDU install package to flash the bootloader. 

Once the bootloader is loaded then you can program the board using the arduino IDE per the instructions on website.  That the double press reset, should make LED blink. 

Good Luck
Trampas



Shai

unread,
Dec 23, 2020, 1:42:30 PM12/23/20
to Smart Stepper
Thanks! I was able to flash the firmware successfully. For anyone curious, had to choose SWD instead of J-link when opening JFlashLite.exe and used default 4000 kHz along with device ATSAMD21G18. 
By the way, what is the recommended distance between the encoder and magnet? I'm using the same magnet https://www.kjmagnetics.com/proddetail.asp?prod=d42dia

misfittech

unread,
Dec 23, 2020, 2:47:06 PM12/23/20
to Smart Stepper
The encoder has a register that shows the signal strength and you can use that to determine distance.  As you mount magnet to metal shaft it changes the field strength so the distance is not always the same.  Generally speaking it seems to work with several millimeters of distance.  Basically you can think of it as the more signal strength the better encoder resolution.  However my experience is the encoder resolution is not the limit of the system. 

Trampas

Shai

unread,
Jan 7, 2021, 4:39:38 PM1/7/21
to Smart Stepper
So I uploaded the firmware to two boards. Didn't modify anything in the firmware. Sometimes it will ask to calibrate on startup and sometimes it says waiting for motor power, even though I didn't touch any wires, just re-uploaded firmware and it stays there. 

However, what I'm having biggest issue with is that the motor hasn't moved at all yet on both boards. I'm not sure why. As the driver chip is out of stock everywhere for months (did you buy all the supply around the world? ;) I had to buy it from this aliexpress link but there's only good reviews so I assume it's good: https://www.aliexpress.com/item/4000202563910.html?spm=a2g0s.12269583.0.0.24de4f73zi0Z0G Do you still use the A4954ELPTR-T or have you replaced it since?

I attached my converted design to Eagle CAD since that's my program of choice. I was wondering if you may have a look to see if something is wrong with the schematic? The only thing I changed from what's on Github is instead of using two resistors to adjust current for 3.3V, I simply swapped out the regulator for a fixed 3.3V output, which is this part: SPX5205M5-L-3-3/TR
I measured and it's about 2.5V output though with a 5V input, but the LCD works fine and I assume the Arduino Zero chip as well. I'm using 24V for the motor supply.

Any help you can offer would be really appreciated. I first cloned it exactly the same to test the design, but I intend to modify it completely once I can ensure it works for a project of mine.
Stepper Encoder v2.brd
Stepper Encoder v2.sch

misfittech

unread,
Jan 7, 2021, 4:58:19 PM1/7/21
to Smart Stepper
including the PDF schematics would be better. 

So on first power up of the board the firmware will try to move the motor a couple of steps.  The firmware does this to determine two things:
1. Motor wiring - is the motor wired for clockwise or counter clockwise rotation. 
2. Degrees per step - Is the motor a 0.9 degree per step or 1.8 degree per step motor. 

If on power up and doing this the encoder indicates the motor did not move, it assumes the board does not have power (you are powering from USB or external 5V/3.3V).  Then it will display no motor power.  If the motor moves and then it says it needs to calibrate the unit as you have not gone through calibration. 

If the board is powered up and not on a motor with magnet then the encoder might think it saw motor move but really did not and give you indication that it is ready for calibration even without a motor attached.   The encoder has some automatic gain control and the firmware is not smart enough to detect when no magnet is there. 

So we need more information to help diagnose the problem, like is board on motor and connected to motor.  Also you can check the diagnostic serial output to see if firmware has found any errors as well. 

As far as the A4954 it appears that Allegro is having supply issues, so you might as well try the Aliexpress. 

Trampas

Shai

unread,
Jan 7, 2021, 5:09:08 PM1/7/21
to Smart Stepper
Sorry about that, here is attached PDF schematic.

I haven't seen, heard or felt the motor move at all and now I can't get past the "waiting for motor power" screen. Everything is fully assembled and it's powered via 5V on VIN pin with the USB disconnected when powering up the board. I'll try the diagnostic serial output, but I feel that is beyond my knowledge as I'm not a programmer.

1. Which pin checks for motor power? I'm wondering if I somehow fried the pin or an IC when messing with plugging in and out the 24V motor wire. Or is there a way to disable the check in firmware?
2. Is there an alternative driver you can recommend? Would prefer to buy genuine ones just to rule out the aliexpress part even though I have a feeling it should work.
Stepper Encoder v2.pdf

Shai

unread,
Jan 7, 2021, 5:11:25 PM1/7/21
to Smart Stepper
Here is a video showing some random behavior without the motor actually moving. This was before the "waiting for motor power" issue: https://youtu.be/CpSITR-OXFM Video might still be processing.

Trampas Stern

unread,
Jan 7, 2021, 6:38:10 PM1/7/21
to Shai, Smart Stepper
Unplugging motor while powered on can fry the driver chip. Specifically from my experience this causes voltage spike on vMot which over voltages driver. I added a zener to vMot at 36v and this seems to reduce this. 

I do not know of a drop in replacement for A5495 driver chip.

As far as pin for detecting vMot voltage your design does not have this that I see in your schematic.

These problems you are having are normal during product development. Things rarely work on first attempt. You need to get a scope and meter and start debugging if it is a hardware issue and if so what problem.


--
You received this message because you are subscribed to the Google Groups "Smart Stepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smart-steppe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smart-stepper/1e0a2e8c-d045-48a5-83e5-92b840848952n%40googlegroups.com.

Shai

unread,
Jan 7, 2021, 6:42:24 PM1/7/21
to Smart Stepper
Can you share more info on the vMot voltage pin detection schematic - how it should look like? Any other issues you were able to find in the schematic?

I also got an S42B from BigTreeTech just in case and it seems even that won't calibrate with the same magnet I used for the Smart Stepper. I'm really confused why. I even unplugged step, dir and EN just in case it was messing with it and only kept 24V, GND, and 5V connected. Still won't calibrate. From YouTube videos, there is a red led that is supposed to turn on their board once calibration starts. I messed around with motor current and EN pin, still nothing. I'm definitely feeding it 24V because I checked with a multimeter. Any ideas? I know it's not your product, but I'm confused why both these products won't even move the motor.

Trampas Stern

unread,
Jan 7, 2021, 7:12:07 PM1/7/21
to Shai, Smart Stepper
So on first power up of the board the firmware will try to move the motor a couple of steps.  The firmware does this to determine two things:
1. Motor wiring - is the motor wired for clockwise or counter clockwise rotation. 
2. Degrees per step - Is the motor a 0.9 degree per step or 1.8 degree per step motor. 

If on power up and doing this movement the encoder indicates the motor did not move, it assumes the board does not have power (you are powering from USB or external 5V/3.3V).  Then it will display no motor power.  If the motor moves and then it says it needs to calibrate the unit as you have not gone through calibration. 

Trampas Stern

unread,
Jan 7, 2021, 7:13:20 PM1/7/21
to Shai, Smart Stepper
So it may be that the motor is not wired correctly or is bad. 

Shai

unread,
Jan 8, 2021, 2:46:25 AM1/8/21
to Smart Stepper
I have two motors I have tried with already, both not working at all. Not with the smart stepper board nor the 2x BigTreeTech ones. Really puzzled on what the issue could possibly be. I'm just feeding it 12V, 5V and GND. All connected properly and checked with multimeter. Not once has any motor moved.

If I were to order one today with an LCD, when can you ship it? Do you have any new ones in stock?

Trampas Stern

unread,
Jan 8, 2021, 8:06:09 AM1/8/21
to Shai, Smart Stepper

I wanted to ask you what is your goal with designing your board? 

You are designing your own stepper board, which a lot of people do and it is fine with me. However most people do this with the thought that it would be a way to learn about electronics, or they think they will get into the market of selling boards.   Some actually think they will save money by building their own. The reality is that the MKS board is very cheap and as such if you are designing a board to sell, your competition is MKS and not me. So people who want to get into this market and sell boards against MKS are in a race to the bottom. 

Some think that they will add custom connectors or other hardware that will give them a market advantage.  This might be true but to sell a product you have to support it and know how it works.  So they are actually again trying to learn. 

If you are interested in learning then you are on the right track.  Specifically you learn by solving these problems. You learn by testing to see if the motor driver chip is good or not and learning how to do that.  
Electrical engineering is not just about math and design, but you need hands on skills.  With any discipline that has hands-on skills you need the tools of the trade.  Auto mechanics need their tools and electrical engineers need their tools.  Scopes, meters, soldering irons, and of course firmware.  

It is like being in the construction grading business, you can not grade a road without a bulldozer, and the bulldozer could cost $200k.  That is you need the tools of the trade. 

These adversities you are having should be embraced and celebrated. For example you have learned that you should never build one unit, or two but the minimum is 3 units because "one is none", two is one.  Three gets you two units and maybe some voting.  You have also learned if you build 3 boards you need parts for 5-10, that is you will fry parts as you learn.  You have learned how to program the bootloader and get the code running.  You are doing great, learn how to test the motor, and how to test the motor drivers.  Read and understand datasheets.  Keep in mind if you are not breaking things you are not learning.    

If you have goals beyond learning, let us know so that we can help you there.  Again if you want to go into business for yourself and sell boards to a niche market go for it.  I initially was upset that MKS did what they did, however I realized that competition is good. Specifically if life had no adversities I would not continue to learn and grow.  
So if you want to go into business consider finding the smartest and best competitor you can.  For example I will tell you exactly how to compete with me if that is what you want.  Actually I guess I did tell you how to compete with me, that is to compete with the smart stepper you need to compete with MKS in a race to the bottom or you learn and innovate new products.  


 

Shai

unread,
Jan 8, 2021, 2:21:47 PM1/8/21
to Smart Stepper
Hi Tampas,

I appreciate the long response, but was honestly just wondering if you had any in stock that I could test to see if it's my setup somehow. Because the BigTreeTech ones also don't work and I tried two of those. This is being used on a PNP, so I need two of these for X/Y and asap so I can test the PNP. The reason for the custom setup is because of how I'd like the connectors to be arranged, but for testing purposes I can rig it.

Thanks,
Shai

Reply all
Reply to author
Forward
0 new messages