I’m guessing the onboard ATTiny is used to convert the “standard arduino” PWM signal to a different PWM frequency / range that the A6211 chip uses ? Are you able to let me know this protocol - I’d like to re-program the ATTiny so that it listens for serial instructions (bytes) and uses those to send the same dimming protocol to control the A6211. Hope this makes sense !
Hi Richard,
You are exactly right about the ATTiny functionality. The code for the Lumen is all available right here. The library use the Arduino Attiny board library by David Mellis and can be compiled in the Arduino IDE set to Attiny45 with 8 Mhz external clock.
You should be able to use a software serial library to accept serial commands instead of PWM, but I imagine there could be code space limitations on the Tiny45. The current code uses 75% of available program space.
Hope this helps!
-Rusty
Perfect, thanks Rusty !
For background, there are plenty of small ROV operators who still have older vehicles with RS232 as control or spare comms. They’re all buying Blue Robotic lights - because they’re great - but can’t dim them unless they install an Arduino or Raspberry Pi. They only need 4 or 5 stages of dimming so hopefully there’s enough space in the Tiny. My plan is to add a couple of components to drop the RS232 to TTL level.
I’ll let you know how it goes.
R
Rusty, I’m having trouble communicating with the ATtiny via Arduino.
I have a Lumen, powered independently. I have an Arduino Uno, connected as follows:
Arduino Pin 13 (SCK) to the Lumen TEMP pad
Arduino Pin 12 (MISO) to the Lumen LED-PWM pad
Arduino Pin 11 (MOSI) to the Lumen SIGNAL pad
Arduino Pin 10 (RESET) to the Lumen RESET pad
Arduino GND to Lumen GND pad
I haven’t connected the Arduino 5v to the Lumen VCC 5v pad, I assume this shouldn’t be needed ?
I haven’t shorted the SJ1 jumper (assume this is if you want to send pwm direct to the A6211).
Arduino IDE is configured Board: ATtiny 25/45/85, Processor: ATtiny45, internal clock 1MHz, Port: Com6 Arduino/Genuino Uno, Programmer Arduino as ISP.
The Lumen is powered via an external supply, Arduino is powered via my laptop.
I load the standard Blue Robotics Lumen Arduino sketch into the Arduino IDE, press upload, it compiles ok but when it tries to upload I eventually get an error message “avrdude: stk500_recv(): programmer is not responding” (it tries 10 times).
Anything obviously wrong in what I’m doing ? Should I be able to upload this way? Should I be using “Burn Bootloader” instead of Uploading ? Do I need to use the Shell file ?
Any help appreciated !
cheers
Rich
Hi Richard,
Thanks for following up. First of all, I don’t think the “Arduino as ISP” method uses the ISP pins from the Arduino - it only connects to the ISP pins on the target. See here for the proper wiring (https://www.arduino.cc/en/Tutorial/ArduinoISP).
Also, you do need to provide power to the Lumen during programming. That can be through the programming header or via external power to the red and black wires.
-Rusty
By the way, I just read your previous post, and you should know that the Lumen signal wires is set up to accept voltages well above TTL levels (up to VIN max) so you don’t need to add any components to handle RS232 levels.
Rusty, once again, you’re a star - thanks ! I’ll have another go over the next few days & let you know progress.
D’oh ! I made an embarrassing rookie mistake, all fixed now.
Thanks again !
Rusty, have you managed to communicate with the ATtiny45 via serial ? I can’t seem to get through to it, I’m using Arduino softwareserial.h, 9600 baud. I’ve defined rx pin as 0 (same as your signal pin), and tried various pins for tx (not used). I’ve tried sending various characters but can’t seem to get a response. I’ve connected the serial GND line to the board ground, and the transmit wire to the yellow wire on the Lumen. I’ve checked that I’m transmitting characters.
Any thoughts appreciated !
Richard,
We haven’t done anything through serial with the Attiny45. Are you sure the software serial library works for it? Also, the Lumen is using some of the hardwire timers to generate PWM signals and since we change the timer settings, that could affect the software serial library.
Here’s the line that changes the timer settings:
TCCR0B = _BV(CS01); // Set prescalar to 8 for 8M/8/256 = 3906 Hz
You might want to comment that out to see if it helps with serial input.
-Rusty
Thanks Rusty,
General consensus is that the serial library works; my first thoughts were that I had to choose a Tx pin, currently got it set at -1 which it should ignore.
I commented out the timer line, and used 1MHz and 8MHz options for the ATtiny. I’m wondering whether the 15k resistor and diode on the Signal_HV line affect the serial signal.
Rich
Hi Rusty,
When I reduce the baud rate to 2400 I get occasional serial characters through, which makes me think there’s a timing issue.
At the moment I’ve tried burning the bootloader for 1Mhz and 8MHz internal clock rates, but just checking - as you have an external 8MHz crystal, do you burn the external 8MHz bootloader ? I’m nervous that I might kill the chip…!
Anyone else out there tried this ?
cheers
Rich
Hi Richard,
Okay, I would definitely recommend using the external 8 Mhz oscillator. It’s much more accurate than the internal clocks.
-Rusty
Thanks Rusty. Tried that; still the same. Stray serial characters get through, but no logic to it.
R
Hilarious ! The only character it seems to accept is “3”, but it recognises it as a “2” ! So dimming works by stepping through brightness levels, each time I press “3”. Would be much neater if I could get it to work properly. Made me laugh though
I’m appealing to any serial buffs out there - anyone know what baud rate to use with the Lumen ? Rusty’s note about resetting TCCR0B presumably affects the serial baud rate (and maybe the addition of the external crystal does too?) I’m using SoftwareSerial on a standalone ATTiny45, works fine. Any thoughts appreciated.
Which pins are you attempting to use for serial?
Do you have a scope?
Can you share your code?
If the same program runs differently on a standalone ATTiny45 than on the lumen board, then the issue is probably the other hardware connected to the microcontroller on the lumen.
Hi Jacob,
I’m using pin 5 for serial in, RS232 level rather than ttl, but via the existing 15k resistor. I don’t have a scope.
Code attached as a text file.
LumenSerial.txt (3.7 KB)
cheers
Rich
Hi Richard,
RS232 is normally inverted signaling compared to TTL serial (low is high and high is low). If you’re using RS232 signals then you would have to set up the software serial to listen to the inverted signals as well.
(From Sparkfun)
-Rusty
I’m such an idiot. Got it, all good now. I’ll need to tidy up the temperature control, and un-comment the frequency lines, but it works nicely. Thanks for your patience all.