@Danal I guess the main goal was to have bed lighting color that I could change using DWC. Then the idea of interfacing it to the printer to change color depending on the printer status came to mind. I am fairly new to Arduino, Raspberry Pi, etc. and when it comes to coding, if I can't find an example to go by, modify, etc. I end up reaching out to others. I struggle to write from scratch and then only basic, simple stuff but I'm slowly learning. If I had a Duet3 board I'd look into the Dotstars instead. You mention these two Wireless type boards and I've seen them before but wasn't sure of being able to make them work for this or how to interface to the Duet. You also mention monitoring the printer status but I wouldn't really know where to begin. I'm always up for a challenge and if you know of better ways to do this please share with me. BTW you have a nice, well written web site, I spent the better part of an hour there a week or so ago!
Posts made by wkellyo
-
RE: How can I control addressable RGB LEDS?
-
RE: How can I control addressable RGB LEDS?
Hi, 1ri wrote the original code and shared with me. I added another color to the existing code, please see this this post and it should explain everything you need. If you need the files, let me know with a private IM and I'll get them to you.
https://forum.duet3d.com/topic/14411/gpio-pins-on-duex5-useage/10
-
RE: GPIO Pins on DUEX5 Useage
For anyone following this I got the Purple color to work perfectly and was sooo close
if (Value_pwm> 625 && Value_pwm <675) {Serial.println (Value_pwm); Serial.println ("Purple"); Purple ();} // M42 P0 S81 in the Duet
This code worked! I originally had an S79 but after taking @Danal advice I got the serial monitor working and studied it and found the PWM value was just a bit short of working. S81 in the code did the trick!
-
RE: GPIO Pins on DUEX5 Useage
@Danal Again, thanks for taking the time to help me. I've read about using the serial monitor, guess it's time to dig in and learn how to use it. I will be changing the Arduino Pin to A3 soon so I can use a 4 Pin shell housing to go from GND, VCC, skip, A3 with one plug. If you would like to see the printer in action Homing watch for the bed leds being in the Sleep mode then going full green while it's homing. After homing, they turn back to sleep. As soon as I get this ironed out, I'll be adding the GCodes to the files as we discussed in macro post. In the video you can see the light change for every direction due to having a "homeall.g file with nothing but pointers to the other homing files. I've rewritten the homeall.g with it's own code so the lights are on during the entire operation. Just looks cleaner to me.
-
RE: GPIO Pins on DUEX5 Useage
@Danal, Yes, it's a 5v pro mini and it's a one way direction from DUEX5 GPIO1 to Pin A2 Of the Pro Mini. I do have a 3.3 to 5v logic level converter device, I should put it in between? If I got a 3.3 v Pro Mini, I'd have more room to add PWM values?
Bottom line, I'm fairly new to Arduino and am trying to learn code. If you look at the first post of the code I've commented what each GCode does, I copied it in again below and bolded the GCodes and Colors. After I got it all working I thought I would try adding another color Purple. That code is bolded in the first post.What you are saying indicates that my guess of 625-675 is above the range. If you study the code I was trying to add (again just copying, pasting and altering the PWM in the same way the other codes are) It won't work. But, if I lower the PWM to say 600-620 or so It might work? If I tighten the ranges of the other colors I could also add more, keeping the last one under 624? I suppose if it's too tight, the arduino may not see the change? I studied the G42 write up but it wasn't clear enough for me. Thank you so much for replying, what you have said has helped me understand this even more.
if (Value_pwm> -1 && Value_pwm <100) {Serial.println (Value_pwm); Serial.println ("Sleep"); Standby ();} // M42 P0 S09 in Duet
if (Value_pwm> 125 && Value_pwm <175) {Serial.println (Value_pwm); Serial.println ("White"); White ();} // M42 P0 S20 in the Duet
if (Value_pwm> 200 && Value_pwm <250) {Serial.println (Value_pwm); Serial.println ("Red"); Red ();} // M42 P0 S29 in the Duet
if (Value_pwm> 275 && Value_pwm <325) {Serial.println (Value_pwm); Serial.println ("Green"); Green ();} // M42 P0 S39 in the Duet
if (Value_pwm> 350 && Value_pwm <400) {Serial.println (Value_pwm); Serial.println ("Blue"); Blue ();} // M42 P0 S49 in the Duet
if (Value_pwm> 425 && Value_pwm <475) {Serial.println (Value_pwm); Serial.println ("Off"); Off ();} // M42 P0 S58 in the Duet
if (Value_pwm> 525 && Value_pwm <575) {Serial.println (Value_pwm); Serial.println ("On"); On ();} // M42 P0 S68 in the Duet -
RE: GPIO Pins on DUEX5 Useage
What I have is GPIO1 of the Duex5 connected to Analog PIN "A2" of an Arduino Pro Mini. In Config.g, I have this to enable the GPIO pin: M950 P0 C"duex.gp1"
I have it all working and can change the addressable LED Lighting colors using the G Codes shown in the sketch code. I use the M42 command such as M42 P0 S20 which changes the LEDS to white. I've added Gcodes to some of the system files that run and the lights change depending on what the printer is doing.
Since I'm not a programmer, I'm not exactly sure what the code is doing when it references: if (Value_pwm> 200 && Value_pwm <250) but just guessing, its reading the PWM value that changes when sending the M42 command.
I was wondering how high I can go with the if (Value_pwm> xxx && Value_pwm <xxx) before exceeding the limits of the Duet System. As my earlier message said, I tried: if (Value_pwm> 625 && Value_pwm <675) without success. Either I goofed the code or sending the M42 P0 S79 didn't do anything. I also tried S73,4,5,6,7,8, and a few after that without success.
-
GPIO Pins on DUEX5 Useage
I use GPIO Pin1 on the DUEX5 to read a PWM value of the various functions of the printer using this Arduino Code which triggers NeoPixel LEDs for Bed Lights using macros and Gcode in the printer files. (I didn't write it A1r did).
My question is what is the min and max range of the PWM Values? These are millisecond values? I attempted to add another color using 625 -<675 as the PWM value and it didn't work. Is 575 as high as I can go? My added code is bolded below in the working code, please scroll down to see. I'm not asking for Arduino Coding just what the PWM range is.
The code below works:
// Command to change led scenarios: M42 P0 Sx (x in multiples of 10. Using GPIO Pin 1 on Duex5 Board)
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define delayLED 5
#define StandbyBrightness 30
#define LowBrightness 75
#define MidBrightness 127
#define HighBrightness 255
#define LED_COUNT 90Adafruit_NeoPixel strip = Adafruit_NeoPixel (LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
// Read pin, connected to pin P0 (GPIO1 on DUEX5) and duex.gp1 for RRF3
byte PWM_PIN = A2;
int Value_pwm;void setup () {
// Start LED strip
pinMode (PWM_PIN, INPUT);
Serial.begin (115200);
strip.begin ();
strip.setBrightness (255);// Initialize the strip
strip.show ();// Start orange sequence
for (int i = 0; i <LED_COUNT; i ++) {strip.setPixelColor (i, strip.Color (255,155,0));
strip.show ();
delay (delayLED);
}
}void loop () {
// Read the value of PWM_PIN and set it to Value_pwm
Value_pwm = pulseIn (PWM_PIN, HIGH);Serial.println (Value_pwm); // Submit the value to monitor sampled values
// comparison of stock strips to have sufficient clearance between stripe and stripe
if (Value_pwm> -1 && Value_pwm <100) {Serial.println (Value_pwm); Serial.println ("Sleep"); Standby ();} // M42 P0 S09 in Duet
if (Value_pwm> 125 && Value_pwm <175) {Serial.println (Value_pwm); Serial.println ("White"); White ();} // M42 P0 S20 in the Duet
if (Value_pwm> 200 && Value_pwm <250) {Serial.println (Value_pwm); Serial.println ("Red"); Red ();} // M42 P0 S29 in the Duet
if (Value_pwm> 275 && Value_pwm <325) {Serial.println (Value_pwm); Serial.println ("Green"); Green ();} // M42 P0 S39 in the Duet
if (Value_pwm> 350 && Value_pwm <400) {Serial.println (Value_pwm); Serial.println ("Blue"); Blue ();} // M42 P0 S49 in the Duet
if (Value_pwm> 425 && Value_pwm <475) {Serial.println (Value_pwm); Serial.println ("Off"); Off ();} // M42 P0 S58 in the Duet
if (Value_pwm> 525 && Value_pwm <575) {Serial.println (Value_pwm); Serial.println ("On"); On ();} // M42 P0 S68 in the DuetI added this under the above using S79 as the trigger. There is also another bit of code at the very bottom, scroll down:
// if (Value_pwm> 625 && Value_pwm <675) {Serial.println (Value_pwm); Serial.println ("Purple"); Purple ();} // M42 P0 S79 in the Duet
}
void Standby () {
// Sequentially put all the LEDs on Standby
strip.setBrightness (StandbyBrightness);
for (int i = 1; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (50,50,50));
strip.show ();
delay (delayLED);
}
while (Value_pwm> -1 && Value_pwm <100)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void White () {
// Sequentially set all LEDs to White
strip.setBrightness (HighBrightness);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (255,255,255));
strip.show ();
delay (delayLED);
}
while (Value_pwm> 125 && Value_pwm <175)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void Red () {
// Set all LEDs sequentially to Red
strip.setBrightness (MidBrightness);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (255,0,0));
strip.show ();
delay (delayLED);
}
while (Value_pwm> 200 && Value_pwm <250)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void Green () {
// Sequentially turn all LEDs to Green
strip.setBrightness (MidBrightness);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (0,255,0));
strip.show ();
delay (delayLED);
}
while (Value_pwm> 275 && Value_pwm <325)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void Blue () {
// Sequentially put all the LEDs to Blue
strip.setBrightness (MidBrightness);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (0,0,255));
strip.show ();
delay (delayLED);
}
while (Value_pwm> 350 && Value_pwm <400)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void Off () {
// Turn off all LEDs sequentially
strip.setBrightness (0);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (0,0,0));
strip.show ();
delay (delayLED);
}
strip.clear ();
while (Value_pwm> 425 && Value_pwm <475)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}
void On () {
// Sequentially turn on all the LEDs
strip.setBrightness (MidBrightness);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (255,128,0));
strip.show ();
delay (delayLED);
}
while (Value_pwm> 525 && Value_pwm <575)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
}My code was added end of the sketch.
void Purple () {
// Turns all LEDs sequentially
strip.setBrightness (0);
for (int i = 0; i <LED_COUNT; i ++) {
strip.setPixelColor (i, strip.Color (255,0,255));
strip.show ();
delay (delayLED);
}
strip.clear ();
while (Value_pwm> 625 && Value_pwm <675)
{Value_pwm = pulseIn (PWM_PIN, HIGH);
}
} -
RE: How do I trigger a macro during Certain Machine operations
Yes, I recognized that one as well. I make use of the mesh bed compensation and each time I run it, a new heightmap.csv file is created. Thanks!
-
RE: How do I trigger a macro during Certain Machine operations
Thanks so much Danal, that's quite a list of possible macros. This should definitely help me out. mrehorstdmd thanks for the tip about using the slicer I may try that as well but I was hoping to keep the printer and the light changes to itself so I don't have to do custom programming in the slicer. Its definitely an option though! Thanks!
-
RE: How do I trigger a macro during Certain Machine operations
Thanks Danal for the positive comments! As the video shows, the lights change to green when the printer is "calibrating" such as homing or bed leveling and after it's done, another GCode dims the lights back to an "Idle" color. I have GCode in the homeall.g file. I also have matching code in the Homez.g, homex.g and homey.g files. My bed lights run from a small arduino connected to a GPIO pin on the DUEX5 board and I'm using M42 to send commands to change the color.
Is it as simple as knowing which file is called during each operation? You mention a begin.g file, I don't have one with that name. Is there a Duet docs link that might explain more about all the various files I could make use of?Here are some other examples I would like to change color with:
When a print starts, which file could the GCode/macro be called from? I don't have a begin.g file....
When a print ends, my gcode would be called from stop.g?
When a print pauses, my gcode would be called from pause.g?
When a print resumes, my gcode would be called from resume.g?Maybe I was simply over analyzing this. I have about 5 colors I'd like to trigger depending on the printer's status.
-
How do I trigger a macro during Certain Machine operations
I have Neopixel Bed lighting that can be controlled using macros. I have one macro that is run when I home the machine since It triggers when clicking the Home All button in DWC which runs the "homeall.g" file in the video you can see the lights turn green.
But... How can I trigger from other actions such as when a print starts, ends, pauses, etc. when there isn't a file I can place code in calling the macro? There are some files that can work but what about when the filament sensor detects an out of filament condition what could be used to trigger a macro for that? Any help and Ideas with this would be greatly appreciated.
-
RE: BLV MGN Cube Neopixel Question
@dc42, I'm not sure. I'm connected to the Duet via Pin 10 of the "Conn_SD" header so whatever it's outputting is what the Arduino is reading. I did find out the gentleman that wrote the Arduino code, said it was only written to monitor tool 0. He offered to rewrite the code to monitor both tools and output the second tool on another Arduino output to a separate Neopixel ring. I've taken him up on the idea and am in the process of adding the fourth Neo Ring to the front panel of the printer.
-
BLV MGN Cube Neopixel Question
Neopixel Question for the group. Using a Duet2 WiFi board with RRF3.0. I have a dual extruder system and am wondering if any other dual extrusion BLV MGN users have encountered this issue and if you did, how you fixed it.
This Printer build uses three Neopixel rings on the front driven by an Arduino Pro Mini connected to the Duet2 board's: "Conn_SD" Pin 10. This output is decoded by the arduino and the three rings report the status of the bed, motion and extruder using color and animations.
The issue is, If I heat up Tool 0, the Heat status lights animate properly. Shutting off Tool 0 heat and heating up Tool 1, There is no heater status and the lights don't animate. For some reason, Conn_SD, Pin 10, used for the Neopixel Lights is only outputting the heat status from Tool 0 only. It's as if the system is only configured with a single tool.
Does anyone familiar with this setup have any idea why?
-
RE: How can I control addressable RGB LEDS?
I messed around with all this today and actually have it working. The Arduino file was a definite challenge as the translation wasn't perfect and I had several errors that had to be fixed. But, it works and now I can tweak it all out to my liking and install the LED strips into the bed light diffusers. Thanks again!
Kelly
-
RE: How can I control addressable RGB LEDS?
@1ri, Bless you! I took a look at the files and other than the task of translating (as you said Google should work very well) I am confident I can make it all work. I have a Duet2 and a Duex5 in my printer so I have lots of available outputs. My goal at first is to simply be able to turn the lights on and off and change the colors via DWC using macros which should be easy enough since you have provided the macros I can modify. I also will have to modify the Arduino code somewhat, probably make it even simpler. Later I may try making them animate when the printer is being used. Thank you so much again!
Kelly
-
RE: How can I control addressable RGB LEDS?
@1ri , would you be willing to share code you have created? While I understand the concepts you've outlined, any specific code for an arduino, macros, etc. would sure help me out as I could see the examples. Maybe you could zip what you have into a single zip file and attach to this post or message me and I'll give you my email address. I'm not much of a programmer but by using examples, I can usually figure stuff out. Thanks so much in advance and if you chose not to, there's no harm in asking.
Kelly -
RE: How can I control addressable RGB LEDS?
1RI, thank you so much for the information, I figured there was a way that even I could understand, this really helps a lot and I even have a few ESP32's laying around besides Nano's, Unos and even a few Mega Arduino's.
-
RE: How can I control addressable RGB LEDS?
3mm thanks for the pointers, I've never heard of them but there sure is a lot of good reading and seems to be better supported. I think I'll head that way.
-
RE: How can I control addressable RGB LEDS?
Thanks for the clarification, Daavery. I was googling tonight and found this: Github LED site and even an arduino sketch that looks doable using the M150 GCode. I could make some Macro's to change the lights. I guess where I'm puzzled is where to connect the arduino GPIO to the Duet. I'm guessing I have to use a particular output and make it available using the minus commands I've seen. Do you know?
-
RE: How can I control addressable RGB LEDS?
Thanks Slam, I'll have to try wrapping my head around this as it might be a bit over my skill level without a lot of research and I still might not get it. Would you happen to know which outputs on the Duet/Duex are able to send out I2C data? Are all of the various outputs carrying this data? If you have any examples or other links of maybe someone that has done this I'd much appreciate it.