#avr Logs

Feb 24 2019

#avr Calendar

01:55 AM rue_mohr: --
02:00 AM rue_mohr: hmm, lcd code isn't working
02:00 AM rue_mohr: hmmmm
07:01 AM jancoow: cehteh: are yo there>?
08:05 AM jancoow: Guys I'm unable to get external interupt working on a attiny414 :/
08:06 AM jancoow: I've configured the pin as input, which is working fine when I simple output it over uart
08:06 AM jancoow: However I want to have an interupt on falling edge. I configured it like this: PORTA_PIN5CTRL = 0x3;
08:17 AM cehteh: jancoow: not really here .. but read datasheet carefully maybe something else is on those pins by default/fuse (jtag for example)
08:18 AM cehteh: or you didnt enabled the interrupt correctly (enable pinchange, set mask enable global interrupts etc)
08:19 AM jancoow: ugh.
08:19 AM jancoow: I opened the wrong schematic (an older one) and the pin was swapped with is neighbour
08:19 AM jancoow: That's was way-to-stupid
08:20 AM cehteh: :D
08:21 AM jancoow: Guess what; it;s working lol.
08:21 AM jancoow: It's not my day today.
09:18 AM jancoow: cehteh hey
09:20 AM jancoow: It's working :d
09:20 AM jancoow: It's dimming light bulbs perfectly
09:21 AM cehteh: nice
09:31 AM jancoow: led bulbs not so nicely. So annoying that these don't dim linair
09:31 AM jancoow: https://photos.app.goo.gl/V2XhSHYak6Qhn6UZ9
09:31 AM jancoow: while regular bulbs dim fine: https://photos.app.goo.gl/AXhjbMPLQprBm3hf9
09:32 AM cehteh: some leds are not dimable
09:33 AM cehteh: (iirc most of them)
09:33 AM cehteh: you get some odd behavior from those
09:33 AM jancoow: yeah
09:33 AM jancoow: this one is dimmable
09:33 AM jancoow: but it's not dimming linear like a regular bulb so need to create some dimming curves or something
01:48 PM rue_mohr: jancoow, 4414?
01:48 PM jancoow: no
01:48 PM rue_mohr: not familiar with a 414
01:48 PM rue_mohr: how many pins?
01:49 PM jancoow: yeah it is working in the mean time :)
01:49 PM rue_mohr: ah,
01:49 PM jancoow: The fault was between chair and keyboard
01:49 PM rue_mohr: still catching up
01:49 PM rue_mohr: add a lookup table to linearalize the output
01:50 PM rue_mohr: or do cds feedback
01:50 PM jancoow: Yeah I'm still thinking of a way to do this dynamicly. I mean; each bulbs has it's own non-liniarity. So I need to program it from my home automation
01:50 PM jancoow: what s cds feedback?
01:51 PM rue_mohr: cds cell?
01:51 PM rue_mohr: light sensor?
01:51 PM jancoow: oh
01:51 PM jancoow: oh right!!
01:51 PM jancoow: that's a great idea
01:51 PM rue_mohr: you can also use an led as a light sensor, but I dont know what the response curve is like
01:52 PM jancoow: I know fibaro dimmers use current sensing
01:52 PM jancoow: I do have a current sensor on this board
01:52 PM jancoow: so I also wanna check if I can use that
01:52 PM rue_mohr: hmm, white leds clearly glow at 10uA
01:56 PM cehteh: pid control for brightness :D
02:04 PM rue_mohr: or just pd
02:05 PM rue_mohr: I suppose technically regulation means that if you turn on another light, it'll dim to reduce its own contribution
02:05 PM jancoow: well just a calibration round is fine
02:05 PM jancoow: the room has to be dark also for calibration
02:05 PM rue_mohr: :) calibrate it during a disco
02:06 PM jancoow: haha
02:06 PM rue_mohr: polprog, cmon, wake up
02:09 PM rue_mohr: splud, did you get your pwm worked out?
02:11 PM splud: rue_mohr - yea, have it working.
02:11 PM splud: I remain puzzled at some of the optimizing donee by the compiler. Would have expected volatile keyword would also have put some weight on not changing the order of operations. That was a curious one.
02:12 PM splud: Note that it wasn't the PWM that was wonky - that was the premise of the project, but the thing that was going sideways was a pin change interrupt for a vibration sensor.
02:13 PM splud: Which had 1K in series to ground, and the 10K internal pullup enabled, so with 5V supply, was < 500uA)
02:13 PM splud: so, wasn't like a big current.
02:14 PM splud: In the end after some other tests, I ended up replacing the vibration switch which was behaving inconsistent.
02:16 PM splud: at max, the program was using 8 bytes of RAM for global states, and another 16 bytes during interrupt handler. so wasn't running out of memory.
02:17 PM splud: (rather stack overrun)
02:17 PM splud: This on ATTiny13A, FTR, so 64 bytes of RAM.
02:17 PM rue_mohr: ah yea
02:18 PM rue_mohr: you needed more than 2 pwm channels
02:18 PM splud: no, 1 pwm was fine.
02:18 PM splud: is/
02:18 PM rue_mohr: ... the t13 has 2...
02:18 PM rue_mohr: you were doing software pwm tho?
02:18 PM splud: t13 has two pins that can be tied to the PWM output, but one timer.
02:19 PM splud: hardware. Software dwell.
02:20 PM splud: Motor controller was the immediate project (with the vibration sensor), but another project running from a conditional build of the same code is a wood smoker (for smoking burgers/sausage for instance).
02:20 PM rue_mohr: oh, are youusing it with a hobby servo?
02:21 PM rue_mohr: this isn't for a dc motor?
02:21 PM splud: That also with an ATTiny13A. PCB is set up with one beefy mosfet for the PWM, then two separate smaller "output enable" fets for the coil and the pump.
02:21 PM rue_mohr: thoguht it was for a 2HP motor
02:21 PM splud: (air pump)
02:21 PM splud: rue_mohr - the motor one is a 2HP treadmill motor, yes.
02:22 PM splud: one PWM output into a two stage RC filter (based on the PWM freq) into an opamp.
02:22 PM rue_mohr: hmm, I lack a large picture
02:22 PM rue_mohr: why not a DAC
02:22 PM rue_mohr: dac is more pins I suppose
02:22 PM splud: because PWM is one output pin, and OpAMP works quite well.
02:22 PM splud: Note, different output voltage.
02:23 PM rue_mohr: ok, so you have pwm line going to a filter to a fet to a 2HP motor, and another pwm going to a coil and...
02:23 PM splud: 12V in from high/low connections from the motor power board, uC PCB has regulator, runs 5V, does PWM into the filter->OpAMP, which converts back up to 12V output to effectively the wiper output terminal to the motor PCB.
02:24 PM splud: On the motor control, no FET on that board.
02:24 PM splud: For PWM smoker control, there's three fets.
02:24 PM rue_mohr: wait, your hacking into the speed control of a motor driver board?
02:24 PM splud: (because the PCB is the entire power driver)
02:25 PM rue_mohr: you do realize how much a picture would assist here
02:25 PM splud: 2HP motor + power supply board from a treadmill. Originally had speed control from a slider potentiometer.
02:25 PM splud: and a fall safety cutoff switch (interrupts AC input with a switch)
02:25 PM rue_mohr: those baords are mains power evil-chopper for the motor drive
02:25 PM splud: fall safety eliminated, not applicable to new purpose.
02:26 PM rue_mohr: ok, so, you do know there are serial operated digital POTs right?
02:26 PM rue_mohr: that can be opto isolated?
02:26 PM splud: Yea, I'm aware. OpAMP is trivial circuit.
02:26 PM rue_mohr: ...
02:26 PM rue_mohr: mkay
02:26 PM splud: and again, 1 pin from the uC.
02:26 PM rue_mohr: mhm
02:27 PM rue_mohr: so on one pin you have a speed control of a treadmill motor using the origional driver
02:27 PM rue_mohr: whats the rest of it doing?
02:28 PM splud: ATTiny: gnd, regulated 5V, reset unused (just ISP, so I can reprogram without HV), ADC for input from pot wiper for the uC to set power, PWM out to filter->OpAMP for motor speed control, two outputs for LED states. and another input for vibration sensor (pin change interrupt).
02:28 PM rue_mohr: huh, ok
02:28 PM splud: uC won't start the motor if it resets and it's pot doesn't read 0 on ADC (i.e. power fault or initial setup and plug in, won't just start running).
02:29 PM splud: vibration sensor causes shutdown (if motor was being driven), and suitable LED state.
02:34 PM splud: Anyway, the PCB for the device is spot on. There was something wrong with the vibration sensor (which was coil spring+ball type), To the point that I eventually unplugges the sensor and just tapped a screwdriver to the terminals and things behaved as they should.
02:35 PM splud: Have other projects using similar table-driven state machine for control, that work just fine. After rewrite on this project, I built version for the smoker and that worked first go.
03:33 PM splud: Had code on the smoker, but was an older non-state machine implementation. "borrowed" that PWM framework as the basis for the motor controller project, and updated it to state machine.
03:33 PM splud: just back inside the shop from stepping outside and snarfing a few sausages off of the smoker <g>
03:34 PM splud: That project though is waiting for it's formal PCB.
03:50 PM treefrob: is this the place to discuss audio-visual receivers?
03:52 PM treefrob: I have a Denon AVR-X1000. I'd like to connect it to my LAN, but I don't trust it. Does anyone have experience firewalling this stuff?
04:24 PM splud: treefrob - er, no. AVR is a family of microcontrollers.
04:26 PM splud: you might try ##networking or similar. Firewalling is straightforward if you have a capable router. Could also connect a PC to it and sniff the traffic.
04:38 PM treefrob: splud, I understand firewalling. Maybe I phrased my question badly. I'm looking for information what how the Denon interacts with the net. What ports it uses, etc
04:39 PM treefrob: reading backward... uh, sorry, I get it now
04:43 PM rue_mohr: splud, hey that cool, you dont see many people using state machines
04:43 PM rue_mohr: esp table driven ones
04:45 PM splud: table driven allows for motor, led, time, next state (say when time runs down). And table can be crammed into flash, not ram.
05:11 PM splud: is a vibration sensor is triggered (or a button pressed, etc), you can call a function to change state, and all output values and timer are set from reading the table.
05:11 PM splud: if a...
05:56 PM mwette: Hi all. I have not dabbled in digital hardware since college in the 1980s. What do people put projects on; we used to do wirewrap. Can you get PCBs produced cheaply?
06:12 PM mwette: the keyword "volatile" tells the compiler not to cache the variable in a register; I don't know what sort of effect it has on ordering instructions
06:19 PM rue_shop1: how to read fuses with avrdude...
06:19 PM nohit: http://blog.atollic.com/volatile-is-better-for-embedded-developers
06:22 PM splud: mwette - yes, I realize volatile keys the compiler to re-read on reference, but given that the compiler chose to change the order of changing a variable to AFTER a function call seemed odd. Wasn't directly related to the issue I was experiencing, but I'd think if the compiler had that variable flagged as volatile, perhaps reordering manipulations would have been a no-no as well.
06:23 PM splud: rue_shop1 - a line from one of my makefiles: avrdude -v -V -p ${AVRDMCU} -c ${PROGRAMMER} -P ${PORT} -C ${AVRDCONF} -U lfuse:w:0x72:m -U hfuse:w:0xff:m -e -F
06:24 PM splud: er, wait, that's setting them. just a sec.
06:24 PM splud: avrdude -v -V -p ${AVRDMCU} -c ${PROGRAMMER} -P ${PORT} -C ${AVRDCONF} -U lfuse:w:0x72:m -U hfuse:w:0xff:m -e -F
06:24 PM rue_shop1: hfuse:r:-: ?
06:24 PM splud: bah. avrdude -V -c ${PROGRAMMER} -p ${AVRDMCU} -P ${PORT} -C ${AVRDCONF} -U flash:r:grab.bin:r -U flash:r:grab.hex:i -U lfuse:r:grab.lfuse.avr:r -U hfuse:r:grab.hfuse.avr:r
06:24 PM rue_shop1: no, not writing them to a file
06:24 PM mwette: splud: makes sense
06:24 PM splud: where "grab.hfuse" is the name of a file it writes the value to.
06:25 PM rue_shop1: but the other thing is that my attemps are telling me that the fuses are all 0
06:25 PM splud: sounds like you don't have the -p set properly.
06:25 PM rue_shop1: -p m88p
06:26 PM splud: though fuses should be at consistent location. config file correct?
06:26 PM splud: good connection - avrdude reports the device validly?
06:26 PM rue_shop1: avrdude: Device signature = 0x1e930f (probably m88p)
06:26 PM rue_shop1: avrdude: safemode: Fuses OK (E:00, H:00, L:00)
06:26 PM splud: hvp reset time...
06:26 PM rue_shop1: ??
06:26 PM rue_shop1: no its talking just fine
06:27 PM rue_shop1: but I think jtag is on
06:27 PM rue_shop1: but it was set up for an arduino bootloader and I dont know what the fuse values are
06:27 PM splud: using ISP interface? Would think RESET would nix that.
06:27 PM splud: but, I have no experience with that mcu.
06:27 PM rue_shop1: its possable to leave jtag on when programming with isp
06:28 PM splud: but would that interfere with _reading_ fuse bits?
06:28 PM rue_shop1: splud, the m48 88 168 and 328 are the same chip
06:28 PM rue_shop1: yea, I'm scratching my head on that one
06:28 PM splud: can you read the flash and eeprom with ISP successfully?
06:29 PM rue_shop1: I didn't try
06:29 PM splud: that above line from my makefile is what I use literally to "grab" the current contents from a device. Like for manual comparison against built binaries, or to save current files before flashing a new image.
06:30 PM rue_shop1: yes it does
06:30 PM splud: On that topic, I've been thinking of taking a partial git commit hash and writing that into EEPROM as a version identifier.
06:31 PM rue_shop1: cat hfuse.hex
06:31 PM rue_shop1: :0100000000FF
06:31 PM splud: So when inspecting a device, I could read the EEPROM and say at the end have 8 bytes that reference the tail end of a git hash, which I could then use to determine the actual build that is loaded.
06:31 PM rue_shop1: cat lfuse.hex
06:31 PM rue_shop1: :0100000000FF
06:31 PM rue_shop1: ???
06:32 PM splud: .hex has address and such
06:32 PM rue_shop1: yes, and if you mentally decode it, it says the values are all zero
06:32 PM splud: okay. you had ??? with no explanation as to what was puzzling to you.
06:33 PM rue_shop1: I'm puzzled cause it looks like all the fuses are 0
06:33 PM rue_shop1: which is basically impossible
06:33 PM splud: Can you read another device successfully?
06:34 PM rue_shop1: I dont have any other m88 to read...
06:37 PM splud: is this something YOU originally programmed?
06:37 PM rue_shop1: I wonder if I can find out what arduino set them to
06:37 PM rue_shop1: yea, I took a blank m88 and put the arduino bootloader on it
06:38 PM rue_shop1: I'll pull it off later, for now its been helping with turnaround time
06:38 PM splud: 62 DF F9 is supposedly the device default according to fusecalc. What Arduino IDE would smack them around to would necessitate snooping in its config.
06:40 PM rue_shop1: iirc they play with the boot address and protection flags
06:41 PM rue_shop1: idea
06:45 PM nohit: rue is using arduino?
06:45 PM rue_shop1: thats what just occured to me, maybe the arduino bootloader cant touch the fuses
06:46 PM LeoNerd: I didn't think bootloaders *can* touch the fuses, can they? I thought only ISP or HVxP
06:46 PM rue_shop1: so with verbose on, I just told it to burn another bootloader
06:47 PM splud: tick tock...
06:48 PM splud: I was under the assumption that you were communicating to the uC with ISP. Bad assumption.
06:48 PM rue_shop1: verifying lfuse memory against 0xe2:
06:48 PM rue_shop1: verifying hfuse memory against 0xd5:
06:49 PM rue_shop1: verifying efuse memory against 0xfc:
06:49 PM rue_shop1: ok
06:49 PM rue_shop1: is jtag off?
06:51 PM rue_shop1: er, there is no jtag flag on it
06:52 PM rue_shop1: ok
06:53 PM rue_shop1: so, back to "why does my lcd not work"
07:01 PM splud: so, how were you running avrdude against it before - just over the serial?
07:01 PM splud: (usbserial) ?
07:04 PM splud: parallel. serial, or I2C (or even SPI) ?
07:04 PM splud: not sure why I'm asking - I've only done OLED and a character based type.
07:06 PM rue_shop1: I just removed everything arduino related
07:06 PM rue_shop1: the lcd still isn't working
07:06 PM rue_shop1: I'm using tested-good code
07:06 PM rue_shop1: for the lcd
07:06 PM rue_shop1: via a 4 bit interface
07:07 PM rue_shop1: I'v used this combination a million times before
07:07 PM rue_shop1: ok I just loaded other code that uses the same lcd connections and everying
07:08 PM rue_shop1: my wiring must be at fault
07:19 PM splud: ah, so this is like a 2-line 20 character LCD?
07:20 PM splud: If so, make sure you have LCD contrast set.
07:20 PM rue_shop1: :-| solder bridge
07:22 PM splud: I have a metric crapton of 2x20 character LCD modiules, with a 2x row of pins down the side. I made adapter PCBs to bring out JUST the connections I needed to connect to a uC, and have a pair of resistors for setting the contrast.
07:22 PM splud: the holes for connecting to the LCD are staggered, so they have a certain friction fit to the module without having to solder it.
07:23 PM rue_shop1: ok fixed
07:23 PM rue_shop1: ugh, that took 12 hours
07:23 PM splud: So a fraction of the time I wasted on a bad vibration switch the other day.
07:24 PM splud: in your case, like 1/20th of a Mooch
07:58 PM mwette: /quit
11:29 PM day_ is now known as day