Alt. firmware and GUI for Thanos's AMC1.5 & AMC1.6

AMC, H-Bridge projects etc.
Please use the image gallery for your pictures, a short tutorial can be found here.
The first image in the first post will be shown in the project gallery.

Alt. firmware and GUI for Thanos's AMC1.5 & AMC1.6

Postby prilad » Tue 24. Jul 2012, 13:27

1. Features of the firmware:

- Firmware is fully compatible with the controller board AMC1.5 (and AMC1.6) by Thanos.

- To configure the firmware can use either a standard terminal program, or special management program - xSimCTRL.exe, supplied with the firmware.

- The firmware uses the modified control algorithm, in contrast to a simple proportional control is used in the original firmware Thanos.

- The speed of the COM port - 115200.

- To control the motors of a 5-byte command in the format:
0x41, 0x42, 0xFF, a0, a1.

- The firmware implements two channel PWM (10 bit resolution), designed to control DC motors through a fee Tronigr's DIY Simple Dual Mosfet H-Bridge. PWM frequency - 18 kHz (18 MHz quartz).

- Period of the main program loop 3.57 ms for the 18 MHz quartz

- During operation of the controller on the LCD displays the following information (in a row for each axis control):
a given position (0 .. 255), sensor readings (0 .. 255), the level of the PWM (-1023 .. 1023), the current Kp
In this case a negative value means the PWM motor rotation in the opposite direction.

- Apply a modified algorithm of the survey feedback sensors (potentiometers). In the firmware includes software thresholds, designed as to limit the working range of the sensors, and for inverting the feedback signals, which can be important when using a Hall sensor. At the same time on the leg ARef microcontroller must be filed with the voltage of 5V.

- Partially supports incremental encoders as the feedback sensors.

2. Description of the control algorithm motors.

At each step of the control (the period of 3.57 ms), the computation of the error of positioning:
Error = SetPos - CurrSens
where

SetPos - position received from x-sim software.

CurrSens - the current value of the sensor feedback (motor current position).


With the implementation of the classical algorithm P-control action is calculated by the formula:
PWM = Error * Kp
where

PWM - the new value of the control signal output,

Kp - coefficient of proportional control.



The modified control algorithm is implemented in this version, as follows:
PWM = minPWM + Error*KpX
where

minPWM - the minimum level of the PWM to the motor,

KpX - dynamically modifiable factor proportional control.

Coefficient minPWM is a constant defined by the user during setup. Setting the value of this coefficient is greater than zero may be true in the case when to start the motor is required to attach to it a high enough voltage.

The coefficient selected KpX program of the two user settable coefficients - KpLo and KpHi. Selecting one of these parameters is carried out when receiving a control command to the new provisions of the axes. In this case, first calculate the absolute value (modulus) of the difference between the new position given Pos (n) and the previous one given position Pos (n-1), and then are selected by the condition:
IF abs( Pos(n) – Pos(n-1) ) > KpTh then

KpX = KpHi

Else

KpX = KpLo


where

KpTh - the threshold value defined by the user.


Thus, the large differences between the new and the previous position specified as the ratio of n-regulatory factor chosen KpHi, and for small - KpLo. This makes it possible to configure different factors in order to prevent overshoot on sharp movements of the axis, not missing in this small vibration.
Upon reaching the axis of the engine it shuts down the specified position.

In addition, to prevent the rocking axis of the non-precision positioning introduced an additional parameter that defines the "dead" zone - minD. If the deviation of the values of the sensor feedback from the given position does not exceed ± minD, the engine is turned off.
By default, the firmware, the following coefficients:

KpLo = 20
KpHi = 10
KpTh = 5
minD = 2
minPWM = 0

Note that when setting KpLo = KpHi, minPWM = 0 and minD = 0, the modified control algorithm is transformed into a classic that is implemented in firmware Thanos.

3. Parameters of feedback sensors (potentiometers)

This firmware implements the following algorithm for processing feedback signals received from the potentiometers.
For each axis of the introduction of two thresholds - SensLo and SensHi. If the sensor readings will be less than the value SensLo (or, respectively, greater than SensHi), the engine stops. And will only move in the opposite direction. Thus, the user can limit the working area of the sensor. In this case the remainder of the range of values between SensLo SensHi and converted into a scale of 0 .. 255.

With the help of the coefficients and SensLo SensHi can also of invert value of the sensor. It's enough to set the value SensLo MORE than SensHi
By default, the firmware, the following values of the coefficients for the two axes:

SensLo = 45
SensHi = 210

These settings allow for potentiometers with an angle of 270 ° to keep the working area of 180 °. In this work area is located in the center of the potentiometer.

If you want to "flip" the sensor, set it SensLo = 210, SensHi = 45

These policy guides are designed to prevent mechanical damage to the sensor in the "flight" through the axis of the extreme positions.

4. The use of incremental encoders

The kit includes the software version of the firmware, which supports the encoders as sensors feedback.
Encoders to be connected to port B of the microcontroller:

PORTB0 .. PORTB1 - the first channel encoder control
PORTB2 .. PORTB3 - the second channel encoder control


To restrict the movement of the axis should be included in the scheme of limit switches applying logic 0 level at operation on port A of the microcontroller

PINA4 - upper switch of Channel Management
PINA5 - the bottom of the first channel control switch


PINA6 - upper switch of the second channel management
PINA7 - the bottom of the second channel switch control


In connection with the firmware included in the encoder initial calibration procedure, which is run by applying 0 (button) on the leg 2 port A. The axis of the sink way down in the trailer and the program fixes the zero position.

The calibration procedure can be caused by feeding the controller messages
0x41, 0x42, 0x7F, 0xXX, 0xXX.
Encoders must be calibrated in a pair, or if at least one axis of the trailer can not be found - the controller has completed the calibration procedure. Exit - just reset the device.

The range of the encoder is configured strictly as firmware, but not in the terminal. Now for the encoder is 1024 pulses per revolution of the range of the angle - 180 °.

5. Using the DIP switches

Dip-switch number 1 (PORTB4) is designed to convert AMC in edit mode parameters using a terminal program.
When editing parameters do not need to enter a value that should not be edited. In response to a query about editing simply press the keypad. Enter to move to the next editable parameter.

Dip-switch number 2 (PORTB5) is designed to determine the mode of positioning axes at the start of the controller.
If the switch is set to "0", then when you turn on the controller will move the axis of the middle position (position = 127). Otherwise, the position of the axes when you turn on the controller will not be changed.

6.Description of program management xSimCTRL

The program is designed to receive data from the AMC Thanos with the firmware from the ALE-SOFT ver.2.0
The program allows you to generate control commands and transmit them to the controller board via RS232. As well as receiving data from the controller to display them as graphs, write a text file for further analysis.
Starting with version 2.0 of the program the opportunity to adjust rates in the firmware of the controller, which is an alternative to the use of the terminal.

The main window is shown in Fig.
xSimCTRL main screen


In fact the appointment of government is clear from their names. In the menu "Settings" to configure the COM port settings - 115200, 8, 1, no parity.

Managing a graphical representation
When pressed RMB (right mouse button) is a graphic image shift. When pressed LMB - scaling. At the same time to zoom down the need for coatings to hold the mouse left to right.
The data, trapped in ZoomBox «thrown open" to all of the window. If you hold down LMB to hold the cursor right to left, then the graph returns to its original scale.
In addition to scaling the image, you can use the mouse wheel.

Sending and receiving data
The transfer of control commands on the AMC begins after you check the box "to include the transfer of" the period specified in the "period (ms)." The user has the ability to specify the position of the axis, either manually or using a software generator, a separate controller for each axis
After you check the box "include taking" the controller goes into transfer mode "telemetry" data to the computer Check the "start recording" includes forwarding the received data to the clipboard image data for output on a computer screen. Buffer Size - or rather, the recording time is specified in the appropriate edit box.

Editing the parameters of the controller
Editing the parameters of the controller is made by introducing new values into the appropriate fields of the program. At the same time transfer the edited parameter to the controller by pressing the key Enter.
The "Save Settings" is intended to make the controller commands save the new setting in the EEPROM. Retained only the data that have been transferred to the controller when editing.


AMC15_mega8535_firmware_byALE_v2.1.rar
AMC1.5 alternative firmware (18 & 22 MHz)
(32.54 KiB) Downloaded 1149 times

AMC16_mega644_22mHz_byALE_fix3.zip
AMC1.6 USB alternative firmware
(13.15 KiB) Downloaded 1122 times

xSimCTRLv2.2eng.rar
GIU for alternative firmware
(329.55 KiB) Downloaded 1210 times

x-sim_AMC_644_ALE_fix3.rar
AMC1.6 atmega644 firmware 18 and 22 MHz, HEX and FTISP files
(42.11 KiB) Downloaded 1103 times


About atmega8535 fuses look...
http://www.x-sim.de/forum/viewtopic.php?f=39&t=237&start=80#p2895

This is small demonstration of new firmware features in video






More videos about using this software you can found here (Thanks to Thanos)

http://www.x-sim.de/forum/viewtopic.php?f=39&t=132

Some words about dip-switch configuration. When I say about dip-switces - I (as programmer ;) ) mean the LOGICAL LEVELS on ports pin. If I say "dip-switch is ON" - it mean DISCONNECT from GROUND and +5V on ports pin.

The startup sequence for using Alt. firmware with terminal progpam (mode TTY, DIP-Swith 1 is OFF)
- set dip-switch 1 OFF (attention! You must change dip-switches before powering AMC, because FW read its position once, when starting)
- connect AMC to PC, set AMC power ON (on LCD line "TTY editing mode"),
- execute the terminal program on PC,
- open and setup COM-port in terminal. You will see empty terminal screen, because the prompt message from AMC was received before program executing.
- reset AMC. This step is needed only in TTY mode and only to check communication with terminal program by receiving prompt message from AMC after resetting,
- follow the screen instruction for changing FW parameters,
- save parameters to EEPROM AMC,
- close terminal program,
- set AMC power OFF,
- set dip-swith 1 ON - this is normal work mode of AMC.

The startup sequence for using Alt. firmware with x-sim software or xSimCTRL software (normal work mode, DIP-Swith 1 is ON)
- set dip-switch 1 ON,
- connect AMC to PC, set AMC power ON (on LCD lines with current AMC values for two axes),
- execute the xSimCTRL program on PC,
- If it FIRST TIME executing or if you CHANGE COM-port, go to "setup" menu, select COM-port and setup it. In any other way you dont need use "setup" menu every time when program is executing. And you dont need reset AMC for begining comunication in this case.
- set checkboxes for working with programm.

PS: This is a project of small group of authors and testers from:

http://mal4x.ru/forum/forums.php?forum=6
Last edited by prilad on Tue 16. Oct 2012, 07:30, edited 11 times in total.
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby prilad » Sun 5. Aug 2012, 15:22

AMC with this firmware send to PC two types of message.

The first one - message with current settings. It has a next format - array of character (string) with length of array = 26 characters.

The first char is "{". The last = "}". Between this chars there are array of chars, each pair of which (except one "quartet") is a hexadecimal digit (parameter) in text format.

- first chars pair - Kp1LO
- the next pair - Kp1HI
- the next pair - Kp2LO
- the next pair - Kp2HI
- the next pair - KpTH
- the next pair - MinDIST
- the next four chars - MinPWM
- the next pair - Sens1LO
- the next pair - Sens1HI
- the next pair - Sens2LO
- the next pair - Sens2HI

For example - "{0A140A14050000FF02FC02FC}"

I draw your attention to the fact that the characters are sent. It means what "0A" is two chars - '0' (ascii code = 0x30) and 'A' (ascii code = 0x41)

The second messages type - message with current values of positions, sensors, PWM and KPs.
This is char array with length = 26 too. But first and last chars are "[" and "]"

- the first chars pair - motor1_set_position
- the next four chars - motor1_get_position (from feedback sensor)
- the next four chars - PWM1 value
- the next pair - current KP1 value
- the chars pair - motor2_set_position
- the next four chars - motor2_get_position (from feedback sensor)
- the next four chars - PWM2 value
- the next pair - current KP2 value

for example - "[05000A003003FA00FA01FF03]"
Last edited by prilad on Sun 5. Aug 2012, 15:35, edited 1 time in total.
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby prilad » Sun 5. Aug 2012, 15:32

Each pair of which (or "quartet") is a hexadecimal digit (parameter) in text format.
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby tronicgr » Sun 5. Aug 2012, 20:56

Hi Prilad

Thanks for that, I'll give it a try when I get my lab settled for programming.

Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby speedy » Tue 11. Sep 2012, 06:34

Great job guys ...
science science science ... at the end ... how AMC is going to communicate with x-sim software ? or how to get in game values to the AMC ?
User avatar
speedy
 
Posts: 148
Images: 4
Joined: Thu 19. Apr 2012, 06:46
Location: Alexandria, Egypt
Has thanked: 14 times
Been thanked: 2 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby prilad » Tue 11. Sep 2012, 07:27

speedy wrote:Great job guys ...
science science science ... at the end ... how AMC is going to communicate with x-sim software ? or how to get in game values to the AMC ?

Hi, speedy. Thank you :D

What do you mean? AMC1.5 alternative firmware compatible only for working with standart x-sim ctrl commands like AB~255~a01~a02 (from PC to AMC). Backward data from AMC can be received only by special software (xSimCTRL), and not implemented for x-sim software.

Unfortunately I do not have experience with a x-sim software yet. My sim project is at a very early stage. But it was important for me to make a own firmware, because I'll use the controller of my own design. And I want to add convenience for AMC users to configure their simulators.

If it are interested, I can continue to develop AMC1.5 and AMC1.6 alternative firmware for fully compatibility with x-sim software.

Redards.
Ale
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Alternative firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby speedy » Wed 12. Sep 2012, 20:31

Sorry If I missed reading the xsimCTRL communicating part ... forgive me my friend :lol: ... I couldn't stop scrolling the page down after 30-40 lines of reading the above un un un unbelievable ... I couldn't help it :lol:
Wow ... this forums can really drive me crazy .


speedy ;)
User avatar
speedy
 
Posts: 148
Images: 4
Joined: Thu 19. Apr 2012, 06:46
Location: Alexandria, Egypt
Has thanked: 14 times
Been thanked: 2 times

Re: Alt. firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby speedy » Mon 24. Sep 2012, 01:14

OK ... my friend Pls. ... I'm really trying hard reading your post ... but my fuse I guess blows fast ... we need a small translation/how to use [ don't give us details on how it works internally ] ...you can put all this stuff in a pdf for who is interested only ... uhhh thanks . :lol:
and for now ... let me ask
q1 : I'm using a FTDI USB UART module on COM4 ,I have tested setting the com port to com4 and the program refused opening this port and it accepts COM1 normally ... Why is that ? Is there any additional settings that can be made for USB ports in the device manager ?

q2 : I guess you suggest sending the FW using pony program ... Is there any easy way to send the FW hex files using the USB port ? ...the it uses bin files

q3 : And after calibrating and testing with the xSimCTRL all the hardware and motors , could the calibrated FW on the ATMEGA 8535/644 receive data from x-sim3 software as you said ... partially compatible [ receive only ] ... and If I can use x-sim3 software should I use the normal string [ AB~255~~a01~~a02~ ] or the the one you wrote before [ AB~255~a01~a02 ] .

If you answered yes for the previous question ... then you gave us a valuable calibration SW before breaking any thing in reality .
prilad wrote:If it are interested, I can continue to develop AMC1.5 and AMC1.6 alternative firmware for fully compatibility with x-sim software.
Redards.
Ale

this option can add a valuable point to the x-xim software ... you should do it ... don't ask .

q4 : what are the Dip switches functions on the AMC board now ... ? are they disabled ?

thanks my friend for your understanding and patience .

speedy ;)
User avatar
speedy
 
Posts: 148
Images: 4
Joined: Thu 19. Apr 2012, 06:46
Location: Alexandria, Egypt
Has thanked: 14 times
Been thanked: 2 times

Re: Alt. firmware and GUI for Thanos's AMC1.5 & AMC1.

Postby prilad » Mon 24. Sep 2012, 08:14

Hi! speedy.

speedy wrote:I'm really trying hard reading your post ... but my fuse I guess blows fast...

Oh, It's not your problem :oops:. It is mine... I know that my english is not good. And "googlenglish" more worse. I'm sorry. 8-)

speedy wrote:q1 : I'm using a FTDI USB UART module on COM4 ,I have tested setting the com port to com4 and the program refused opening this port and it accepts COM1 normally ... Why is that ? Is there any additional settings that can be made for USB ports in the device manager ?

As I know - no. All COM ports (real or virtual like FTDI USB UART) should works equally. I say more, I'm using a FTDI USB UART module too. Only one thing is different - you should plug-in USB device into PC BEFORE starting program xSimCTRL.
Can you write me more details about this problem? What OS (Win XP or Win 7, x32 or x64 system?) do you use? COM4 is present in xSimCTRL "setup" menu?
Just in case, you can try to check comunication with AMC by using the terminal program... You can set DIP-switch #1 and (after resetting AMC) try to communicate with AMC from terminal (with COM4).

speedy wrote:q2 : I guess you suggest sending the FW using pony program ... Is there any easy way to send the FW hex files using the USB port ? ...the it uses bin files

As I know (maybe I'm wrong) to send FW without programmer possible with special BootLoader, like in Arduino. I'm not use BootLoader yet.

speedy wrote:q3 : ... and If I can use x-sim3 software should I use the normal string [ AB~255~~a01~~a02~ ] or the the one you wrote before [ AB~255~a01~a02 ] .

You should use the normal string [ AB~255~~a01~~a02~ ]. :) . My wrong "string" is result "unknowing" sim software yet :oops:

speedy wrote:q4 : what are the Dip switches functions on the AMC board now ... ? are they disabled ?

Dip-switch #1 configure AMC to work in TTY mode. You can adjust the AMC parameters without xSimCTRL. And you can check connection to AMC from the terminal program.
Dip-switch #2 configure AMC to automatically axes moving to the center position when power is turned on.
Another DIP-switches are disabled.

Good luck and best regards,
Ale.

PS: As I understand it - you use AMC1.6 ?
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Alt. firmware and GUI for Thanos's AMC1.5 & AMC1.6

Postby speedy » Tue 25. Sep 2012, 07:49

Hi prilad !
OK ... really thanks for things that I understand for now ...but Pls. ... lower your expectations to me in programing world ... and accept my apology my talent is not here ... :cry:

You still didn't give me what I need ... so let me rephrase my questions slowly ... and a step by step ...

First step ... How do I flash the ATMEGA 644/8535 with your FW ? ... cause I didn't pass this yet to use dip switches ... let me know also if there is any settings to do before that ... or can you provide a one click batch file that does every thing for me ... recommended choice. :lol:

Second step ... I'm using a win7 Ultimate x86 ,AMC1.6 Thanos board ,and the terminal program (that's on Thanos's post first page ) for the FTDI is communicating well with the FTDI USB UART module on COM4 ,and programing the ATMEGA successfully with Thanos FW with the help of the batch files that Thanos provided next to his FW !!! ...
So ... next ... and without unplugging any thing ... I then go to your xSimCTRL program and select the com-port setup and select the COM4 that the FTDI uses ... it still gives me a message "CAN'T OPEN PORT " even after restarting the windows ,Why is that ? ... Is it because I didn't flash the ATMEGA with your FW yet ? ...
I have some know how to change the port No. in the device manager ... Should I do So ? ... I guess that even without flashing the ATMEGA with your FW ,at least the program should connect to the AMC !!! ...

I know that Thanos did all of this and worked good ... but there is no written instructions that can be translated ... only videos .

thanks and best regards ...
speedy ;)
User avatar
speedy
 
Posts: 148
Images: 4
Joined: Thu 19. Apr 2012, 06:46
Location: Alexandria, Egypt
Has thanked: 14 times
Been thanked: 2 times

Next

Return to Controllers and Drivers Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron