How to wiring correctly? - hoantv/CarSimulatorFirmware GitHub Wiki

IMPORTANCE: You must connect as bellow to make the firmware work properly.

Encoder

Pull up with 1k resistor.

A ------> PA0

B ------> PA1

Z ------> PA2

Check the direction of the wheel on debug tab. When it turns left, xAxis descrease and vice versa. If not, exchange Pa0 and pa1

Note in Control Mode:

  • 0..50..100 mode is danger. so from V1, I add PE7 use to active servo driver (when stm32 connect to power, it will be high)

  • PE8 as Dir in signal/dir.

Internal DAC

  1. PA4 for using one analog(signal/dir, 0..50..100)
  2. PA4, PA5 for using 2 analog(signal+-) External DAC MCP4922
  3. Output1 for using one analog(signal/dir, 0..50..100)
  4. Output1, Output2 for using 2 analog(signal+-) wiring like the shematic in page 27 https://ww1.microchip.com/downloads/en/devicedoc/22250a.pdf
PB12 - CS MCP
PB13 - SCK MCP

PB14 - LDAC MCP

PD15 - SDI MCP

PWM

  1. PE9 for using one PWM(signal/dir, 0..50..100)

  2. PE9, PE11 for using 2 analog(signal+-)

Analog

PC0,1,2,3

Button

matrix 5*5

  • column PC6,7,8,pa8,pa9
  • row pd11,12,13,14,15

IMPORTANCE

You must isolate your STM32 and your servo by using optocoupler if you use AC servo, for example with PC817:

                                                    5V (STM32)
                                                     |
                                                     |
                                                   R1000
                                                     |
                                                     |
 A +  —-R330---> PIN1 PC817 ------------PIN4 PC817 ----------------> PA0


 A -  —-R330---> PIN2 PC817 ------------PIN3 PC817 ----------------> GND (STM32).

Same for B+/B- and Z+/Z- (3 x PC817 are needed in total).