Alternative to PWM spindle

Home Forums TinyG TinyG Support Alternative to PWM spindle

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #10527
    Mark81
    Member

    I’m afraid I’ve accidentally burned the PWM spindle output. Now the output is fixed at 150 mV whatever settings I choose. By the way, these are my current settings:

    
    [p1frq] pwm frequency              1000 Hz
    [p1csl] pwm cw speed lo               0 RPM
    [p1csh] pwm cw speed hi            1000 RPM
    [p1cpl] pwm cw phase lo           0.000 [0..1]
    [p1cph] pwm cw phase hi           1.000 [0..1]
    [p1wsl] pwm ccw speed lo              0 RPM
    [p1wsh] pwm ccw speed hi           1000 RPM
    [p1wpl] pwm ccw phase lo          0.000 [0..1]
    [p1wph] pwm ccw phase hi          1.000 [0..1]
    [p1pof] pwm phase off             0.000 [0..1]

    I would be able to replace the MCU and flash the bootloader, but I need to disconnect everything and the case is not easily accessible. I wonder if there is a way to use a different pin to output a PWM.

    I gave a quick look to the code and I see there is a “secondary” PWM that seems not used.

    Any idea?

    #10528
    cmcgrath5035
    Moderator

    Anyone who says “I would be able to replace the MCU and flash the bootloader” immediately gets a bit of questioning respect, please don’t be offended:

    We are talking tinyG, not G2core(DUE), correct?

    Interface did work for you with the settings you attach?
    They look OK, but I have never seen anyone set speed hi to 1000 RPM.

    I am not a developer, but have seen reference to PWM2 on G2Core.
    Looking in tinyG/pwm.c, I do see reference to PWM2, but in an ifdef __ARM block, which is DUE code (common code base), I believe.

    Assuming an ‘electrical event’ damaged the I/0 port pin hardware, are you thinking using a different output port on the XMEGA?
    Which one?
    I am not sure there are any unused Ports.
    Schematics here

    What you ask about here is really beyond the normal scope of this Forum.
    I’d suggest you post a question at

    Add info related to my questions above.
    The Issues area is much closer to the developers.

    It might be useful info to report if the Spindle PIN (simple on/off control) still operates properly

    Good Luck with your fix

    • This reply was modified 7 years, 2 months ago by cmcgrath5035.
    #10530
    Mark81
    Member

    I’m not offended at all. I’m quite new to tinyG (yes, tinyG, not G2) and perhaps I might be wrong but as far as I understand the project is opensource. Hence, it should be enough to de-solder the xmega and replace it with a new one (which I have in my drawers) and using AtmelStudio to flash the hex of the bootloader before download the latest firmware. Is it correct?

    Yes, the PWM worked a while without any connection on the terminal blocks. I’m pretty sure I accidentally connected the wrong wire (it was too early in the morning, gh…). The spindle pin works fine but I don’t understand your question: it’s on a different port (PA5). It would be more useful to know if other pins of PORTD still work, wouldn’t it? Anyway, they seem to work…

    About my question: I’m not talking of spare pins, but “unused” ones in my application. Example, from here: https://github.com/synthetos/TinyG/blob/master/firmware/tinyg/pwm.c#L67 it seems the spindle PWM comes from the CCB of TCD1 (PD5). From the schematic the coolant (PE5) is instead CCB of TCE1.

    This one is not used (https://github.com/synthetos/TinyG/blob/master/firmware/tinyg/pwm.c#L71) so swapping timers should do the trick. After a quick look to the code it seems both timers are used only for PWM (though I don’t understand what is the purpose of the secondary PWM).

    If you think I’m off-topic I will open an issue on github.

    #10531
    cmcgrath5035
    Moderator

    I’m not offended at all. I’m quite new to tinyG (yes, tinyG, not G2) and perhaps I might be wrong but as far as I understand the project is opensource. Hence, it should be enough to de-solder the xmega and replace it with a new one (which I have in my drawers) and using AtmelStudio to flash the hex of the bootloader before download the latest firmware. Is it correct?

    You are Correct.
    The tooling and skills required for this is not typical for Forum users, including myself.

    Yes, the PWM worked a while without any connection on the terminal blocks. I’m pretty sure I accidentally connected the wrong wire (it was too early in the morning, gh…). The spindle pin works fine but I don’t understand your question: it’s on a different port (PA5). It would be more useful to know if other pins of PORTD still work, wouldn’t it? Anyway, they seem to work…

    That question had two motivations. 1, determine if you knew how to turn PWM on and off. Obviously, you do. 2, Get a rough feel for how much damage to the I/O structure on the XMEGA had been done. I fully agree that determining functionality on Port D would be a good thing before proceeding. As well as looking at chip physical layout to see what else might be in the vicinity of the Port D5 output structure.
    Here is a good reference if you don’t already have it

    Is the Coolant I/O pin functional? If so, and not used by your application, recompiling with the PWM connected to the Coolant external port might be your quickest try.

    Very few Forum users are equipped to handle the gory details of recompile tinyG, folks off on that tangent do tend to head directly to the Issues interface for advice.
    It is not a question of off-topic, more that you might attract input from other tinyG users working at the recompile level over at Issues, as well as the developers.

    If your Coolant lead is still functional, give it a go.

    Good Luck !

    • This reply was modified 7 years, 2 months ago by cmcgrath5035.
    #10533
    Mark81
    Member

    I swapped the timers in the code, recompiled and downloaded using avrdude. It works! I have my PWM back 🙂

    #10534
    cmcgrath5035
    Moderator

    Way cool!

    For the record, can you post here the changes you made?

    Congratulations

    #10535
    Mark81
    Member

    I swapped the timers in pwm.c:

    
    #define PWM1_CTRLA_CLKSEL	TC_CLKSEL_DIV1_gc
    #define PWM1_CTRLB 		(3 | TC0_CCBEN_bm)
    #define PWM1_ISR_vect 		TCE1_CCB_vect	
    #define PWM1_INTCTRLB		0		
    
    #define PWM2_CTRLA_CLKSEL 	TC_CLKSEL_DIV1_gc
    #define PWM2_CTRLB 		3
    //#define PWM2_CTRLB 		(3 | TC0_CCBEN_bm)
    #define PWM2_ISR_vect		TCD1_CCB_vect	
    #define PWM2_INTCTRLB		0		
    

    and also in hardware.h:

    
    #define TIMER_PWM1			TCE1
    #define TIMER_PWM2			TCD1
    

    then I swapped the gpio assignments:

    
    #define SPINDLE_PWM		0x01
    #define MIST_COOLANT_BIT	0x02
    #define FLOOD_COOLANT_BIT	0x02
    
    #10552
    cmcgrath5035
    Moderator

    So, back on the proper thread.
    Can you post the tinyG binary you built and successfully tested after making
    these changes ?

    I swapped the timers in pwm.c:

    #define PWM1_CTRLA_CLKSEL TC_CLKSEL_DIV1_gc
    #define PWM1_CTRLB (3 | TC0_CCBEN_bm)
    #define PWM1_ISR_vect TCE1_CCB_vect
    #define PWM1_INTCTRLB 0

    #define PWM2_CTRLA_CLKSEL TC_CLKSEL_DIV1_gc
    #define PWM2_CTRLB 3
    //#define PWM2_CTRLB (3 | TC0_CCBEN_bm)
    #define PWM2_ISR_vect TCD1_CCB_vect
    #define PWM2_INTCTRLB 0
    and also in hardware.h:

    #define TIMER_PWM1 TCE1
    #define TIMER_PWM2 TCD1
    then I swapped the gpio assignments:

    #define SPINDLE_PWM 0x01
    #define MIST_COOLANT_BIT 0x02
    #define FLOOD_COOLANT_BIT 0x02

    There is a user on the Ox Forum with PWM issues similar to yours, although we have yet to verify that he still has workable Coolant port I/O.
    Thanks

    #10553
    Mark81
    Member

    Ok, so you want the swapped pwm/coolant version, but without the laser mode. I will compile and upload this version for you this evening.

    #10555
    Mark81
    Member
    #10556
    cmcgrath5035
    Moderator

    Thanks!

    #10557
    cmcgrath5035
    Moderator

    Mark81 – No surprise to you,
    I was able to install the binary to my test platform with avrdude and verify the swap of Coolant (M8) and SpinPWM ports works.
    Thanks again.

    For anyone reading this thread, the binary Mark81 built still reports $fb=440.20, exercise care if you download it.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.