Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.49k stars 5.32k forks source link

Support for sam3xc controller #1121

Closed drphil3d closed 5 years ago

drphil3d commented 5 years ago

how would one go about adding support for a SAM3X8C based controller? I have the pin configuration file. I'm just not familiar with 32 bit controllers and don't quite know where to start. https://github.com/synthetos/g2/blob/master/g2core/board/printrboardg2/printrboardG2v3-pinout.h

nikhil8333 commented 5 years ago

It is already a 32 bit controller hence I think there is no need for a raspberry Pi to help in resources, and if your question is about standalone support I.e. running klipper completely on SAM3X8C I think those boards lack megabytes of ram which is necessary for a python compiler like micro python for better performance. But In my opinion 32bit controllers are in there best with reprap firmware and marlin supporting greater functionalities. Klippers sole function is to upgrade 8bit controller to work with performance of 32 bit controllers by using an interpreter like raspberry Pi . And does not burden us with overpriced 32bit controllers

drphil3d commented 5 years ago

I understand that, I don't think you understand what I'm doing. https://vectormfg.net/klipper-multi-mcu/

Read the bottom of this page https://github.com/KevinOConnor/klipper/blob/master/docs/Features.md

Klipper makes it possible to use the raspberry pi as a host device and the 8bit or 32bit Atmel MCU only for sending signals to the stepper motors and other outputs. The article I wrote above explains the benefits.

nikhil8333 commented 5 years ago

I clearly understand, but the issue I'm stating is 32 bit controllers are already expensive, and support multiple extruders or steppers like duet wifi which has support of additional 5 steppers other than 1X,1Y,2Z,2E. my point is instead of including expensive hardware we can use multiple 8 bit boards. yes there are boards like arduino due which are inexpensive being 32bit. but I feel why waste resources which are not necessary as 8bit controllers perform way better connected to rpi/klipper.

drphil3d commented 5 years ago

There is still a limit to resolution and speed with an 8bit controller granted that limit is incredibly high. There is already 32bit arm support in klipper for 3sam8xe just not 8xc and I literally have piles of printrboad g2 controllers that I and many other people would really like to be able to use.

KevinOConnor commented 5 years ago

It's not difficult to add support for the sam3x8c. If you're willing to run tests on the hardware I can provide a test branch. Let me know.

-Kevin

drphil3d commented 5 years ago

Yes I would be very happy to

On Thu, Jan 17, 2019 at 7:53 AM KevinOConnor notifications@github.com wrote:

It's not difficult to add support for the sam3x8c. If you're willing to run tests on the hardware I can provide a test branch. Let me know.

-Kevin

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1121#issuecomment-455222810, or mute the thread https://github.com/notifications/unsubscribe-auth/AUK_9hUGlLTQNkIiBuWyxcwtL4M9twBGks5vEJyBgaJpZM4aDxQd .

--

Philip Mally 3D Printing & Rapid Prototyping Services 530-205-3210 pmally@gmail.com

KevinOConnor commented 5 years ago

I've uploaded a development branch with initial support for the sam3x8c mcu:

cd ~/klipper ; git fetch ; git checkout origin/work-sam3x8c-20190118 ; make menuconfig ; make ; sudo service klipper stop ; make flash ; sudo service klipper start

Note that this does not have USB support (only serial). I'm not sure how the Printrboard G2 is wired so I don't know if that is important or not.

-Kevin

drphil3d commented 5 years ago

when I used the 3x8c in the past it would show up on my computer as having two serial ports one a control port and the other a data port but you could use either one it didn't matter. I will try flashing it this afternoon. looks like the g2core firmware exposes two usb serial ports. https://github.com/synthetos/g2/blob/master/g2core/board/printrboardg2/board_xio.h

I found the pin file https://github.com/synthetos/g2/blob/master/g2core/board/printrboardg2/motate_pin_assignments.h

how to I convert these hardware pin numbers to something klipper can use?

Thank you so much by the way for your hard work!

KevinOConnor commented 5 years ago

FYI, I was able to bring up USB support for the SAM3X series. If you pull the latest version of the code you can now compile with USB support if you need that.

cd ~/klipper ; git fetch ; git checkout origin/work-sam3x8c-20190118 ; make menuconfig ; make ; sudo service klipper stop ; make flash ; sudo service klipper start

Klipper uses the micro-controller names for the pins - they have names like PA23 and PB7. I don't know what pin naming convention those headers are using (though it looks like the header linked in the original post can be easily translated to the micro-controller names).

-Kevin

drphil3d commented 5 years ago

ok after a bit of strutting I got it flashed 🗡 bossac-cli must be installed on linux

you have to activate the bootloader by opening a connection at 1200 baud stty -F /dev/ttyACM0 1200 hup

to flash pi@octopi:~/klipper/out $ bossac --port=ttyACM0 -U true -e -w -v -i -b -R klipper.elf.hex

https://github.com/synthetos/g2/wiki/Flashing-g2core-with-Linux pi@octopi:~/klipper/out $ stty -F /dev/ttyACM0 9600 pi@octopi:~/klipper/out $ bossac --port=ttyACM0 -U true -e -w -v -i -b -R klipper.elf.hex Erase flash Write 61394 bytes to flash [==============================] 100% (240/240 pages) Verify 61394 bytes of flash [==============================] 100% (240/240 pages) Verify successful Set boot flash true Device : ATSAM3X8 Chip ID : 284e0a60 Version : v1.1 Dec 15 2010 19:25:04 Address : 524288 Pages : 2048 Page Size : 256 bytes Total Size : 512KB Planes : 2 Lock Regions : 32 Locked : none Security : false Boot Flash : true

drphil3d commented 5 years ago

I'm creating a config file, I searched the repo for mentions of DRV8825 and only found a few mentions. I'm just trying to figure out where the micro-step pin numbers need to be specified

Here are the pins for the 4 stepper drivers supported by g2 board MS1 Slaved Drive DIR pin STEP pin ENDSTOP pin EN pin Vref Microstep 2 Pin MS2 Microstep 0 Pin
X A16 B15 B26 B16 B17 A19 M1_MS2 A20
Y A26 A21 A11 A25 B18 B20 M2_MS2 B21 M2_MS0
Z B1 A29 A10 B0 B19 A27 M3_MS2 A28 M3_MS0
E0 B23 B14 B22 A2 B10 M4_MS2 B11

[driver drv8825_32] type = DRV8825 microsteps = 16

A4 BED ADC

A23 Extruder1 ADC

B3 INDICATOR_LED

B12 RGBW Neopixel Pin B13

pin_number kOutput1_PinNumber = 130; // DO_1: Extruder1_PWM pin_number kOutput2_PinNumber = 131; // DO_2: Extruder2_PWM pin_number kOutput3_PinNumber = 132; // DO_3: Fan1A_PWM pin_number kOutput4_PinNumber = 133; // DO_4: Fan1B_PWM pin_number kOutput5_PinNumber = 134; // DO_5: Fan2A_PWM pin_number kOutput9_PinNumber = 138; // SAFE signal pin_number kOutput10_PinNumber = 139; // DO_10: Fan2B_PWM pin_number kOutput11_PinNumber = 140; // DO_11: Heated Bed FET pin_number kOutput12_PinNumber = 141; // DO_12: Indicator_LED

pin_number kADC0_PinNumber = 150; // Heated bed thermistor ADC pin_number kADC1_PinNumber = 151; // Extruder1_ADC pin_number kADC2_PinNumber = 152; // Extruder2_ADC pin_number kADC3_PinNumber = 153; // Aux ADC

KevinOConnor commented 5 years ago

The "make flash" command should work - the syntax would be something like: make flash FLASH_DEVICE=/dev/ttyACM0

Use a static_digital_output config section for the MS pins - see config/generic-rambo.cfg for an example and config/example-extras.cfg for a description of the config section.

-Kevin

drphil3d commented 5 years ago

after flashing the board and power cycling It no longer shows up under dmesg or lsusb and the red light is on. the same light that comes on when you press reset button. So I think I flashed it with something it didn't like.

Edit: just found this on the g2 wiki

The red lights just mean the board is in bootloader mode. You haven't bricked the board. :smile:

the code you provided above doesn't work for flashing

Edit 2: I jumped reset and erase to get back into bootloader mode. Tried flashing again but it wont exit bootloader so I figured it may have issue with the file I'm flashing. I converted the file to a bin and flashed but that didn't work either.

bossac --port=ttyACM0 -U true -e -w -v -i -d -b -R klipper.elf.hex

arm-none-eabi-objcopy -I ihex --output-target=binary klipper.elf.hex klipper.bin

drphil3d commented 5 years ago

I've tried pulling the code again, clean make file, tried with and without usb, etc. due boards wont flash with avrdude they have to have bossac. I can flash the hex file generated but it doesn't like it and just stays in booloader mode. I can flash g2core firmware just fine. tinyg is the old firmware g2core is the most recent firmware just for clarification.

http://ww1.microchip.com/downloads/en/AppNotes/Atmel-42728-Using-SAM-BA-for-Linux-on-SMART-ARM-based-Microcontrollers_ApplicationNotes_AT15004.pdf

does this help at all? https://github.com/synthetos/Motate/blob/master/MotateProject/motate/platform/atmel_sam/atmel_sam.cfg

KevinOConnor commented 5 years ago

If you compile the micro-controller code for the SAM3X series (via make menuconfig) then make flash will invoke bossac. If this isn't working, please run: cd ~/klipper ; make clean ; make menuconfig ; make ; make flash FLASH_DEVICE=/dev/ttyACM0 and then cut-and-paste the entire terminal output to this github issue.

-Kevin

drphil3d commented 5 years ago

pi@octopi:~/klipper $ cd ~/klipper ; make clean ; make menuconfig ; make ; make flash FLASH_DEVICE=/dev/ttyACM0 scripts/kconfig/mconf /home/pi/klipper/src/Kconfig

End of the configuration. Execute 'make' to start the build or try 'make help'.

Build Kconfig config file Creating symbolic link out/board Compiling out/src/sched.o Compiling out/src/command.o Compiling out/src/basecmd.o Compiling out/src/debugcmds.o Compiling out/src/gpiocmds.o Compiling out/src/stepper.o Compiling out/src/endstop.o Compiling out/src/adccmds.o Compiling out/src/spicmds.o Compiling out/src/thermocouple.o Compiling out/src/i2ccmds.o Compiling out/src/pwmcmds.o Compiling out/src/lcd_st7920.o Compiling out/src/lcd_hd44780.o Compiling out/src/buttons.o Compiling out/src/tmcuart.o Compiling out/src/avr/main.o Compiling out/src/avr/timer.o Compiling out/src/avr/gpio.o Compiling out/src/avr/adc.o Compiling out/src/avr/spi.o Compiling out/src/avr/i2c.o Compiling out/src/avr/hard_pwm.o Compiling out/src/avr/watchdog.o Compiling out/src/avr/usbserial.o Compiling out/src/generic/usb_cdc.o Building out/compile_time_request.o Version: v0.7.0-97-gd942eb2-20190122_034448-octopi Linking out/klipper.elf Creating hex file out/klipper.elf.hex Flashing out/klipper.elf.hex to /dev/ttyACM0 via avrdude

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding ^Csrc/avr/Makefile:32: recipe for target 'flash' failed

KevinOConnor commented 5 years ago

You've set the target to an AVR board. You need to run "make menuconfig" and navigate the menu system there to select the SAM3X8C target. Then run "make clean" then run "make flash FLASH_DEVICE=/dev/ttyACM0"

-Kevin

drphil3d commented 5 years ago

YaY! that worked! the problem was I kept giving it a name when it asked to save the config

pi@octopi:~ $ cd ~/klipper ; make clean ; make menuconfig ; make ; make flash FLASH_DEVICE=/dev/ttyACM0 scripts/kconfig/mconf /home/pi/klipper/src/Kconfig

End of the configuration. Execute 'make' to start the build or try 'make help'.

Build Kconfig config file Creating symbolic link out/board Compiling out/src/sched.o Compiling out/src/command.o Compiling out/src/basecmd.o Compiling out/src/debugcmds.o Compiling out/src/gpiocmds.o Compiling out/src/stepper.o Compiling out/src/endstop.o Compiling out/src/adccmds.o Compiling out/src/spicmds.o Compiling out/src/thermocouple.o Compiling out/src/i2ccmds.o Compiling out/src/lcd_st7920.o Compiling out/src/lcd_hd44780.o Compiling out/src/buttons.o Compiling out/src/tmcuart.o Compiling out/src/atsam/main.o Compiling out/src/atsam/gpio.o Compiling out/src/atsam/i2c.o Compiling out/src/atsam/spi.o Compiling out/src/generic/crc16_ccitt.o Compiling out/src/generic/alloc.o Compiling out/src/generic/armcm_irq.o Compiling out/src/generic/timer_irq.o Compiling out/src/atsam/sam3_usb.o Compiling out/src/generic/usb_cdc.o Compiling out/src/atsam/adc.o Compiling out/src/atsam/timer.o Compiling out/src/../lib/sam3x/gcc/system_sam3xa.o Compiling out/src/../lib/sam3x/gcc/gcc/startup_sam3xa.o Building out/compile_time_request.o Version: v0.7.0-97-gd942eb2-20190122_034937-octopi Linking out/klipper.elf Creating bin file out/klipper.bin Building bossac make[1]: wx-config: Command not found make[1]: wx-config: Command not found CPP APPLET src/WordCopyArm.cpp CPP COMMON src/Samba.cpp CPP COMMON src/Flash.cpp CPP COMMON src/D5xNvmFlash.cpp CPP COMMON src/D2xNvmFlash.cpp CPP COMMON src/EfcFlash.cpp CPP COMMON src/EefcFlash.cpp CPP COMMON src/Applet.cpp CPP COMMON src/WordCopyApplet.cpp CPP COMMON src/Flasher.cpp CPP COMMON src/Device.cpp CPP COMMON src/PosixSerialPort.cpp CPP COMMON src/LinuxPortFactory.cpp CPP BOSSAC src/bossac.cpp CPP BOSSAC src/CmdOpts.cpp LD bin/bossac Flashing out/klipper.bin lib/bossac/bin/bossac to /dev/ttyACM0 via bossac Erase flash

Done in 0.030 seconds Write 18556 bytes to flash (73 pages) [==============================] 100% (73/73 pages) Done in 0.657 seconds Verify 18556 bytes of flash [==============================] 100% (73/73 pages) Verify successful Done in 0.613 seconds Set boot flash true

[27349.470435] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device [27350.679637] usb 1-1.3: USB disconnect, device number 34 [27351.176395] usb 1-1.3: new full-speed USB device number 35 using dwc_otg [27351.526375] usb 1-1.3: device descriptor read/64, error -32 [27351.789406] usb 1-1.3: New USB device found, idVendor=2341, idProduct=abcd [27351.789419] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [27351.789428] usb 1-1.3: Product: Klipper firmware [27351.789436] usb 1-1.3: Manufacturer: Klipper [27351.789445] usb 1-1.3: SerialNumber: 12345 [27351.790434] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device

lsusb Bus 001 Device 035: ID 2341:abcd Arduino SA

drphil3d commented 5 years ago

Awesome thank for your help! Now on to converting that pin file, the first version I made didn’t work sense the pin names aren’t arduino PIN format and the documentation on this mcu is sparse and hard to understand for someone who isn’t well versed in micro controllers.

KevinOConnor commented 5 years ago

Great! I've committed the sam3x8c changes to the master branch (commit eb7842c2).

If you run into a road block with the configuration then you can attach the klipper.log file (see https://github.com/KevinOConnor/klipper/blob/master/docs/Contact.md ) and we can take a look (though I'm not sure there is much we can do to help). I suggest starting with config/generic-rambo.cfg and make sure to change all of the pins (everywhere there is a PA7/PH4/PJ2/etc pin in that file, be sure to change it to PA23/PB12/etc in the new file). If you get a working config, it would be good to add it to the Klipper repo.

-Kevin

drphil3d commented 5 years ago

It's Working! I'm reading the thermistor tempature values. However when I plugged in the stepper motors and homed the motors didn't move just wined and the board got super hot. I'm going to keep working at it but the outlook is good.

drphil3d commented 5 years ago

ok this is the last part I need some guidance on: setting the Vref voltage using pwm

the board has integrated DRV8825 drivers with vref mapped to PB17, PB18, PB19, PA2

edit: I looked in the extras section and found

most the options I try give errors start and shutdown values must be 0.0 or 1.0 on soft pwm The stepper motors make noise when they are homed with these values but the board gets very hot and I immediately turn it off [output_pin my_pin] pin: PB17 pwm: 1 value: 1 shutdown_value: 0 cycle_time: 0.100

scale:2

my head hurts

this is just code I've pulled out of the g2 source to figure things out. PWMOutputPin<vref_num> _vref; _vref{kNormal, frequency},


void setPowerLevel(float new_pl) override { if (!_vref.isNull()) { _vref = new_pl; } };

// sets default pwm freq for all motor vrefs (commented line below also sets HiZ)
StepDirStepper(ioMode step_polarity, ioMode enable_polarity, const uint32_t frequency = 250000) :
    Stepper{},
    _step{step_polarity==IO_ACTIVE_LOW?kStartHigh:kStartLow},
    _enable{enable_polarity==IO_ACTIVE_LOW?kStartHigh:kStartLow},
    _vref{kNormal, frequency},
    _step_polarity{step_polarity},
    _enable_polarity{enable_polarity}
{};

// Stepper power management settings

define Vcc 3.3 // volts

define MaxVref 2.25 // max vref for driver circuit. Our ckt is 2.25 volts

define POWER_LEVEL_SCALE_FACTOR ((MaxVref/Vcc)) // scale power level setting for voltage range

KevinOConnor commented 5 years ago

It sounds like a pwm controlled voltage reference pin. You'd want something similar to what's found in config/generic-mini-rambo.cfg . Unfortunately, that requires hardware pwm support which has not been implemented for the sam3x.

-Kevin

drphil3d commented 5 years ago

I see, makes sense why it rejects the code. darn 🤔 thats too bad, I will just have to wait until that happens.

KevinOConnor commented 5 years ago

I took a look, and it doesn't seem simple to implement.

If you're feeling daring, you could try the following (be quick to pull the power if anything goes wrong):

[output_pin motor_x_pwm]
pin: PB17
pwm: True
scale: 2.25
cycle_time: 0.0001

Then at runtime manually send a SET_OUTPUT_PIN PIN=motor_x_pwm VALUE=0.5 (where value is the desired amps) via the OctoPrint terminal to enable power to the motor.

-Kevin

drphil3d commented 5 years ago

Awesome I'm getting somewhere with this. got the x stepper moving with out overheating and freaking out, it's super weak but it's moving. this command gives an error SET_OUTPUT_PIN PIN=motor_x_pwm VALUE=0.5 Recv: // Unknown command:"SET_OUTPUT_PIN"

[mcu] serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00 baud: 250000

[stepper_x] step_pin: !PB15 dir_pin: PA16 enable_pin: !PB16 step_distance: .005 endstop_pin: !PB26 position_endstop: 0 position_max: 170

[stepper_y] step_pin: PA21 dir_pin: PA26 enable_pin: !PA25 step_distance: .005 endstop_pin: PA11 position_endstop: 0 position_max: 220

[stepper_z] step_pin: PA29 dir_pin: PA1 enable_pin: !PA0 step_distance: .005 endstop_pin: PA10 position_endstop: 0 position_max: 190

[extruder] step_pin: PB14 dir_pin: PB23 enable_pin: !PB22 step_distance: .002 nozzle_diameter: 0.400 filament_diameter: 1.750 heater_pin: PA5 sensor_type: EPCOS 100K B57560G104F

sensor_pin: PA23

sensor_pin: PA4 control: pid pid_Kp: 22.2 pid_Ki: 1.08 pid_Kd: 114 min_temp: 0 max_temp: 250

[heater_bed]

heater_pin: PB24

sensor_type: EPCOS 100K B57560G104F

sensor_pin: PA4

control: watermark

max_temp: 110

[fan] pin: PA6

pin: PB25

pin: PB27

[heater_fan nozzle_cooling_fan]

pin: B25

[printer] kinematics: cartesian max_velocity: 400 max_accel: 3000 max_z_velocity: 25 max_z_accel: 30

[output_pin motor_x_pwm] pin: PB17 pwm: True scale: 2.25 cycle_time: 0.0001

[static_digital_output 16xmicrostep_config] pins: PA19, PB20, PA27, PB10

KevinOConnor commented 5 years ago

I meant SET_PIN PIN=motor_x_pwm VALUE=0.5

-Kevin

drphil3d commented 5 years ago

Yay! that works. I don't know how the software pwm is going to affect print quality I think i can hear the pwm as the motor turns.

drphil3d commented 5 years ago

after going through the config trying to tidy things up and get it all working I realized that the lack of hardware pwm makes many things unusable. extruder, heated bed, fans, etc. oh well

KevinOConnor commented 5 years ago

FYI, hard pwm does not provide a benefit to heaters or fans, and Klipper does not use it for that purpose on any platform.

However, hard pwm is needed for setting of stepper voltage levels, and soft pwm would not work well in that role. (It's purely about frequency of updates - .0001 is 10000 updates a second, whereas it looks like the original config uses 250000 updates per second.) I would be curious, however, if you could verify the mapping of all the vref pins on the G2. (Their choice of PA2, which is a timer pin, is odd considering the other pins appear to be PWMC pins.)

-Kevin

drphil3d commented 5 years ago

oh interesting, that makes sense to me. I did find a file in the g2 firmware that looked like it was possibly remapping some of the pin configurations upon compiling. I will have to find it and show you, that could explain some of the strange pin mapping.

drphil3d commented 5 years ago

https://github.com/xzw168/g2Crop/blob/master/Motate/MotateProject/motate/Atmel_sam_common/motate_pin_assignments.h

this file confuses me

https://github.com/Sorveno/G2_core/blob/master/g2core/board/printrboardg2/motate_pin_assignments.h

// For the SAM3X8C boards, we actually use the same NUMBERING, but have different number to pin linkages

I don't fully understand what's going on here but it would seem to me that A2 is assigned to multiple pins but it's being used for ADC not Vref

// PWM Pin assignments
// Stupid preprocessor! Workaround for the comma in the TimerChannel name:

define _MOTATE_TEMP_TC(t,c) Motate::TimerChannel<t,c>

_MAKE_MOTATE_PWM_PIN('A',  0, Motate::PWMTimer<3>, /*Peripheral:*/ B, /*Inverted:*/ false);
_MAKE_MOTATE_PWM_PIN('A',  2, _MOTATE_TEMP_TC(1,0),            /*Peripheral:*/ A, /*Inverted:*/ false);
_MAKE_MOTATE_PWM_PIN('A',  3, _MOTATE_TEMP_TC(1,1),            /*Peripheral:*/ A, /*Inverted:*/ false);

// ADC Pin assignments _MAKE_MOTATE_ADC_PIN('A', 2, / ADC number:/ 0)

// SAM3X8C doesn't have a PORT C or D

https://github.com/synthetos/Motate/blob/master/MotateProject/motate/Atmel_sam3x/motate_chip_pin_functions.h

drphil3d commented 5 years ago

Ok I have XYZ homing correctly and I can move all axis properly after setting pwm frequency What doesn’t work yet: heaters Fans Neopixel - super low priority

Here is a video of it homing https://youtu.be/TWWShRl1PCg

[mcu] serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00 baud: 250000

[force_move]

enable_force_move: True

[stepper_x] step_pin: PB15 dir_pin: !PA16 enable_pin: !PB16 step_distance: .0125 endstop_pin: ^PA11 position_endstop: 0 position_max: 200 homing_speed: 30 homing_retract_dist: 3.0 second_homing_speed:20

[output_pin motor_x_pwm] pin: PB17 pwm: True scale: 2.25 cycle_time: 0.00001

[stepper_y] step_pin: PA29 dir_pin: !PB1 enable_pin: !PB0 step_distance: .0125 endstop_pin: ^PB26 position_endstop: 0 position_max: 150 homing_speed: 30 homing_retract_dist: 5 second_homing_speed:20 homing_positive_dir:true

[output_pin motor_y_pwm] pin: PB19 pwm: True scale: 2.25 cycle_time: 0.00001

[stepper_z] step_pin: PA21 dir_pin: PA26 enable_pin: !PA25 step_distance: .0025 endstop_pin: ^!PA10 position_endstop: 0 position_max: 220 homing_speed: 30 homing_retract_dist: 3.0 second_homing_speed:8

[output_pin motor_z_pwm] pin: PB18 pwm: True scale: 2.25 cycle_time: 0.00001

[extruder] step_pin: PB14 dir_pin: PB23 enable_pin: !PB22 step_distance: .002 nozzle_diameter: 0.400 filament_diameter: 1.750 heater_pin: PA5 sensor_type: EPCOS 100K B57560G104F sensor_pin: PA23

sensor_pin: PA4

control: pid pid_Kp: 22.2 pid_Ki: 1.08 pid_Kd: 114 min_temp: 0 max_temp: 250

[output_pin motor_e_pwm] pin: PA2 pwm: True scale: 2.25 cycle_time: 0.00001

[heater_bed]

heater_pin: PB24

sensor_type: EPCOS 100K B57560G104F

sensor_pin: PA4

control: watermark

max_temp: 110

[fan] pin: PA6

pin: PB25

pin: PB27

[heater_fan nozzle_cooling_fan]

pin: B25

[printer] kinematics: cartesian max_velocity: 350 max_accel: 2000 max_z_velocity: 10 max_z_accel: 300 square_corner_velocity: 5.0

[static_digital_output step_config] pins: PA19, PB20, PA27, PB10

drphil3d commented 5 years ago

well I can home xyz and move around just fine but the fans and heaters don't work

KevinOConnor commented 5 years ago

Does the board have a global enable pin that must be set for the heaters / fans to be enabled?

-Kevin

drphil3d commented 5 years ago

Not that I’m aware of. It has a uart output or it could be input but I kind of doubt it that it globally disables anything. In the g2core pin file it says safe signal rx tx that sends a signal of some kind from the MCU which is confusing because there are two mcu. The printer has an esp8266 mounted on the front of the machine with a touch screen to control it. --

KevinOConnor commented 5 years ago

I'm pretty sure the Klipper gpio code is working (it's tested on sam3x8e; it works on sam3x8c for steppers). So, the likely explanation is an error in pin definitions or there is something board level (such as enable pins) that needs to be implemented.

Unfortunately, I don't have much advice on that - having a schematic for the board would help, but it doesn't look like there is one available.

-Kevin

drphil3d commented 5 years ago

I can see about getting the board schematic. Thank you for all your help, much appreciated.

On Sun, Jan 27, 2019 at 7:48 AM KevinOConnor notifications@github.com wrote:

I'm pretty sure the Klipper gpio code is working (it's tested on sam3x8e; it works on sam3x8c for steppers). So, the likely explanation is an error in pin definitions or there is something board level (such as enable pins) that needs to be implemented.

Unfortunately, I don't have much advice on that - having a schematic for the board would help, but it doesn't look like there is one available.

-Kevin

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1121#issuecomment-457929025, or mute the thread https://github.com/notifications/unsubscribe-auth/AUK_9l9Yx48RfSx8rwp4E8Hscd3b5abZks5vHcpqgaJpZM4aDxQd .

--

Philip Mally 3D Printing & Rapid Prototyping Services 530-205-3210 pmally@gmail.com

KevinOConnor commented 5 years ago

Any further updates on this?

-Kevin

drphil3d commented 5 years ago

We have been working on it, slowly making progress. https://github.com/MarlinFirmware/Marlin/issues/13020

KevinOConnor commented 5 years ago

Interesting. That's one strange heater/fan enable pin. Out of curiosity, if the following is added to your printer.cfg file:

[output_pin heater_enable]
pin: PA7
pwm: True
cycle_time: .050

and then run SET_PIN PIN=heater_enable VALUE=.004 at startup, does it allow you to use the fans/heaters?

-Kevin

drphil3d commented 5 years ago

Check this out, have the heaters working in marlin2.0 thanks to Bob.

https://github.com/MarlinFirmware/Marlin/issues/13020#issuecomment-462086437

Excerpts of the Pin file // Heaters / Fans //

define HEATER_0_PIN 40 // G2 says PA5 DO_1

define HEATER_BED_PIN 41 // G2 says PB24 DO_11

ifndef FAN_PIN

define FAN_PIN 13 // PB27 DO_4 Fan1A

endif

define FAN1_PIN 58 // was 60 // PA6 DO_3 Fan1B

define FET_SAFETY_PIN 31 // PA7 must be pulsed low every 50 mS or FETs are turned off

define FET_SAFETY_DELAY 50 // 50 mS delay between pulses

define FET_SAFETY_INVERTED true // true - negative going pulse of 2 uS

/ G2 uses 8 pins that are not available in the DUE environment 34 PA29 - Y_STEP_PIN 35 PB1 - Y_DIR_PIN 36 PB0 - Y_ENABLE_PIN 37 PB22 - E0_ENABLE_PIN 38 PB11 - E0_MS1_PIN - normally used by the USB native port 39 PB10 - E0_MS3_PIN - normally used by the USB native port 40 PA5 - HEATER_0_PIN 41 PB24 - HEATER_BED_PIN None of these are in the arduino_due_x variant so digitalWrite and digitalRead can't be used on them. Can access via FASTIO but they must be under 78 /

KevinOConnor commented 5 years ago

FYI, I added support for hard pwm, at least for pins PB17, PB18, PB19 (commit 090cd930).

-Kevin

drphil3d commented 5 years ago

Oh sweet thank you! So that means we should have an operational board including the FETs. Awesome, I just gotta test it.

drphil3d commented 5 years ago

When I home the machine It hardly moves under its own power then gives an error Recv: !! Internal error on command:"G28" klippy.log

KevinOConnor commented 5 years ago

You'll need to set hard_pwm=True for the PB17/PB18/PB19 lines, and set the values in the config. Look at config/generic-mini-rambo.cfg as an example. Use a cycle_time=.000004 (which is 250Khz). For now, I'd say just don't use the e motor (hardware pwm isn't available for the PA2 pin yet).

-Kevin

KevinOConnor commented 5 years ago

FYI, the error is likely because you've set homing_positive_dir=True for stepper_y when that should not be set. Remove that option from the config.

-Kevin

drphil3d commented 5 years ago

still getting the same issue where it can hardly move. at least it's super quiet now, I don't hear the squealing beeping like before.

drphil3d commented 5 years ago

omg hahaha silly me forgot to set the pwm value. Is there a way to have it pull this value so I don't have to enter it every time at runtime? SET_PIN PIN=motor_x_pwm VALUE=0.5

KevinOConnor commented 5 years ago

Yes - use hard_pwm and set a static_value in the config - see config/generic-mini-rambo.cfg for an example. (Again, this wont yet work for the PA2 e motor pin.)