ODroid as raplacement for Raspberry Pi

More
3 years 8 months ago #264613 by rodw
I think we can do better than that.
Not sure how yet, but I think you could write a timer interrupt routine to do hardware stepping and control the step frequency... for speed.
I have done this on an arduino to drive a stepper and the ISR (interrupt service routine was only a few lines of code.
But I cheated and just turned the pins on and off as a square wave. It worked, but they ran hot!

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #264614 by rodw
Hmm ChatGPT came up with this

Certainly! Here is an example of a timer interrupt service routine for an ARM Cortex-A CPU that toggles a GPIO pin at a frequency controlled by a variable that can be changed in real-time:
Code:
#include <stdint.h> #include "arm_gic.h" // Include the appropriate GIC (Generic Interrupt Controller) file for your specific ARM CPU #define GPIO_PIN_NUM 10 // The number of the GPIO pin to toggle #define TIMER_INTERRUPT_ID 30 // The ID of the timer interrupt to use #define CLOCK_FREQ_MHZ 100 // The frequency of the clock in MHz volatile uint32_t tick_count = 0; volatile uint32_t frequency_mhz = 1; // The frequency to toggle the GPIO pin in MHz void timer_interrupt_handler(void) { tick_count++; // Increment tick count on every timer interrupt // Toggle the GPIO pin based on the frequency setting if (tick_count % (CLOCK_FREQ_MHZ / frequency_mhz) == 0) { toggle_gpio_pin(GPIO_PIN_NUM); } // Clear the interrupt flag in the GIC arm_gic_clear_interrupt(TIMER_INTERRUPT_ID); } void set_frequency_mhz(uint32_t freq_mhz) { frequency_mhz = freq_mhz; } int main(void) { // Initialize system clock and peripherals // Note: the exact initialization code will depend on your specific ARM CPU and board // Configure the GPIO pin as an output configure_gpio_pin_output(GPIO_PIN_NUM); // Configure the timer interrupt arm_gic_configure_interrupt(TIMER_INTERRUPT_ID, ARM_GIC_PRIORITY_MEDIUM, timer_interrupt_handler); // Enable the timer interrupt arm_gic_enable_interrupt(TIMER_INTERRUPT_ID); while (1) { // Your main program code here // Call set_frequency_mhz to change the frequency setting in real-time } }
 
In this example, we assume that there are functions toggle_gpio_pin and configure_gpio_pin_output available to toggle the GPIO pin and configure it as an output. The frequency_mhz variable is used to set the frequency of the GPIO pin toggle operation. The timer_interrupt_handler function is called on every timer interrupt and toggles the GPIO pin at the specified frequency. The set_frequency_mhz function can be called from the main program to change the frequency setting in real-time. Note that we assume that CLOCK_FREQ_MHZ is a constant representing the frequency of the clock in MHz.

Note that this is just an example and may need to be modified to work with the specific ARM CPU and peripherals you are using. The exact initialization code and the implementation of the toggle_gpio_pin and configure_gpio_pin_output functions will depend on your specific ARM CPU and board.

Not bad...

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #264615 by rodw
And I asked it to include a step length which defines the length of a pulse that runs at a specific frequency,
so now I juat need it to scale it by steps per mm/inch so we can set the speed in linuxcnc hal based on the feed rate.
Scary!
But yes hardware stepping should be possible.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #264616 by rodw
hmm.
This is now a framework for a driver
Warning: Spoiler!

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #264617 by rodw
Phew!
we reformatted the code to use a PREEMPT_RT thread!
Not bad so I saved it in drive
docs.google.com/document/d/1OjpibGOAtL11...qpY/edit?usp=sharing

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #264666 by rodw
So it seems my Netgear router at home has flakey support for NTP in its DHCP service. I changed the router settings to use pool.ntp.org.
It seems Netgear has issues with NTP...
On a bug report I filed,  johnag has pushed a fix to use Debian's NTP server if one is not provided by DHCP. Not sure how long it takes to get to his downloads...

He covers how to extend  the partion in his FAQ's  Tips and Tricks
sd-card-images.johang.se/tips-and-tricks.html
Also covers the missing Dialog error I experienced there too.
 

Please Log in or Create an account to join the conversation.

Time to create page: 0.213 seconds
Powered by Kunena Forum