writing chip conveyor component , user input wanted
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
26 Feb 2024 00:17 #294474
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
Aight, I am formulating the code plan for a few days in my head, like, how exactly I plan to write it all, the code structure etc. Gotta chew on all this and start writing function drafts while I'm not busy.
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
26 Feb 2024 12:55 #294512
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
sketching out the deadman switch, anybody see any errors here, this will block the rest of the program and set output flags.
// Initialize deadman_timer
int deadman_timer = 10;
int switch_triggered = 0;
// Update deadman_timer based on deadman_reset and switch_triggered
if (*deadman_reset == 1) {
// Reset deadman_timer to 10
deadman_timer = 10;
switch_triggered = 0;
} else if (*hall_effect_switch == 1 && switch_triggered == 0) {
// Hall effect switch triggered, reset switch_triggered
switch_triggered = 1;
} else if (switch_triggered == 1) {
// Decrement deadman_timer by 1
deadman_timer -= 1;
}
// Update deadman_switch based on deadman_timer
if (deadman_timer <= 0) {
*deadman_switch = 0; // Deadman switch is off
// Perform program shutdown here
// For example:
// exit(1); // Exit the program with an error code
} else {
*deadman_switch = 1; // Deadman switch is on
}
// Initialize deadman_timer
int deadman_timer = 10;
int switch_triggered = 0;
// Update deadman_timer based on deadman_reset and switch_triggered
if (*deadman_reset == 1) {
// Reset deadman_timer to 10
deadman_timer = 10;
switch_triggered = 0;
} else if (*hall_effect_switch == 1 && switch_triggered == 0) {
// Hall effect switch triggered, reset switch_triggered
switch_triggered = 1;
} else if (switch_triggered == 1) {
// Decrement deadman_timer by 1
deadman_timer -= 1;
}
// Update deadman_switch based on deadman_timer
if (deadman_timer <= 0) {
*deadman_switch = 0; // Deadman switch is off
// Perform program shutdown here
// For example:
// exit(1); // Exit the program with an error code
} else {
*deadman_switch = 1; // Deadman switch is on
}
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
26 Feb 2024 19:57 - 26 Feb 2024 20:04 #294545
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
just using chat GPT to sketch out the some code and logic flow. This will obviously need debugging etc. Just a quick start to the framework of the component.
// Initialize conveyor_out
int conveyor_out = 0;
float conveyor_time_on = 0.0; // Time in seconds conveyor is on
float conveyor_time_off = 0.0; // Time in seconds conveyor is off
float conveyor_cycle_time = 0.0; // Total cycle time (on + off)
float conveyor_cycle_timer = 0.0; // Timer to keep track of cycle time
float after_run_timer = 0.0; // After-run timer
float after_run_time = 0.0; // After-run time
// New branch logic
int enable_outputs = 0;
float outputs_timer = 0.0; // Timer for enabling outputs
float outputs_time = 0.0; // Time for enabling outputs
// Reset timers when conveyor is enabled
if (*spindle_enable == 1) {
conveyor_out = 0; // Reset conveyor_out
after_run_timer = 0.0; // Reset after-run timer
enable_outputs = 0; // Reset enable_outputs flag
outputs_timer = 0.0; // Reset outputs timer
}
// Update conveyor_out based on spindle_enable
if (*spindle_enable == 1) {
// Spindle is enabled
if (*conveyor_mode == 0) {
// Conveyor mode 0: Run conveyor_out 100%
conveyor_out = 1;
} else {
// Conveyor mode 1: Adjustable on/off cycle
if (conveyor_cycle_timer <= 0) {
conveyor_out = !conveyor_out; // Toggle conveyor_out
if (conveyor_out) {
// Conveyor is on, set cycle time to conveyor_time_on
conveyor_cycle_timer = conveyor_time_on;
} else {
// Conveyor is off, set cycle time to conveyor_time_off
conveyor_cycle_timer = conveyor_time_off;
}
} else {
// Decrement cycle timer
conveyor_cycle_timer -= 0.001; // Assuming 1 ms cycle time
}
}
// Reset the outputs timer when spindle is enabled
outputs_timer = outputs_time;
// After-run timer logic
if (after_run_timer > 0) {
after_run_timer -= 0.001; // Assuming 1 ms cycle time
} else {
after_run_timer = after_run_time;
conveyor_out = 0; // Turn off conveyor_out after after_run_time
enable_outputs = 1; // Enable outputs during after run
}
} else {
// Spindle is disabled, conveyor_out is off
conveyor_out = 0;
// Enable outputs during after run
if (enable_outputs) {
if (outputs_timer > 0) {
// Enable outputs
// For example: *output1 = 1;
outputs_timer -= 0.001; // Assuming 1 ms cycle time
} else {
enable_outputs = 0; // Disable outputs
// Clear the flag when outputs are disabled
}
}
}
// Use conveyor_out for other functions
// Initialize conveyor_out
int conveyor_out = 0;
float conveyor_time_on = 0.0; // Time in seconds conveyor is on
float conveyor_time_off = 0.0; // Time in seconds conveyor is off
float conveyor_cycle_time = 0.0; // Total cycle time (on + off)
float conveyor_cycle_timer = 0.0; // Timer to keep track of cycle time
float after_run_timer = 0.0; // After-run timer
float after_run_time = 0.0; // After-run time
// New branch logic
int enable_outputs = 0;
float outputs_timer = 0.0; // Timer for enabling outputs
float outputs_time = 0.0; // Time for enabling outputs
// Reset timers when conveyor is enabled
if (*spindle_enable == 1) {
conveyor_out = 0; // Reset conveyor_out
after_run_timer = 0.0; // Reset after-run timer
enable_outputs = 0; // Reset enable_outputs flag
outputs_timer = 0.0; // Reset outputs timer
}
// Update conveyor_out based on spindle_enable
if (*spindle_enable == 1) {
// Spindle is enabled
if (*conveyor_mode == 0) {
// Conveyor mode 0: Run conveyor_out 100%
conveyor_out = 1;
} else {
// Conveyor mode 1: Adjustable on/off cycle
if (conveyor_cycle_timer <= 0) {
conveyor_out = !conveyor_out; // Toggle conveyor_out
if (conveyor_out) {
// Conveyor is on, set cycle time to conveyor_time_on
conveyor_cycle_timer = conveyor_time_on;
} else {
// Conveyor is off, set cycle time to conveyor_time_off
conveyor_cycle_timer = conveyor_time_off;
}
} else {
// Decrement cycle timer
conveyor_cycle_timer -= 0.001; // Assuming 1 ms cycle time
}
}
// Reset the outputs timer when spindle is enabled
outputs_timer = outputs_time;
// After-run timer logic
if (after_run_timer > 0) {
after_run_timer -= 0.001; // Assuming 1 ms cycle time
} else {
after_run_timer = after_run_time;
conveyor_out = 0; // Turn off conveyor_out after after_run_time
enable_outputs = 1; // Enable outputs during after run
}
} else {
// Spindle is disabled, conveyor_out is off
conveyor_out = 0;
// Enable outputs during after run
if (enable_outputs) {
if (outputs_timer > 0) {
// Enable outputs
// For example: *output1 = 1;
outputs_timer -= 0.001; // Assuming 1 ms cycle time
} else {
enable_outputs = 0; // Disable outputs
// Clear the flag when outputs are disabled
}
}
}
// Use conveyor_out for other functions
Last edit: 26 Feb 2024 20:04 by smc.collins.
Please Log in or Create an account to join the conversation.
27 Feb 2024 19:50 #294633
by chris@cnc
Replied by chris@cnc on topic writing chip conveyor component , user input wanted
Our two suggestions are close together. I didn't include washing out. spontaneous but no idea either. theoretically one interval cycle time would be enough for washing out. can you follow my idea of the timer?
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
28 Feb 2024 02:36 #294653
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
Yeah, i haven't added all of the timer logic as of yet.
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
10 Mar 2024 02:36 #295554
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
Quick update, I'm debugging some of the timers and setting bits, there's actually surprising amount of logic going on in this component.
Maybe a release for testing in 2 weeks.
Maybe a release for testing in 2 weeks.
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 684
- Thank you received: 119
11 Nov 2024 03:07 #314225
by smc.collins
Replied by smc.collins on topic writing chip conveyor component , user input wanted
I finally am able to get back after this, what a yr so far.
Please Log in or Create an account to join the conversation.
Time to create page: 0.092 seconds