#avr Logs

Apr 07 2020

#avr Calendar

03:44 AM evidlo2: I think this is alright, but could someone verify that my dual use of MOSI and RST is OK? https://i.imgur.com/hM23vzD.png
04:42 AM skz81: evidlo2, unsure what you want to do, but that seems strange. RESET and GPIO are exclusive on this pin
04:42 AM skz81: see RSTDISBL fuse
04:43 AM skz81: • RESET/PCINT14 – Port C, Bit 6RESET, Reset pin: When the RSTDISBL fuse is programmed, this pin functions as an input pin, and the part will have to rely on power-on reset and brown-out reset as its reset sources. When the RSTDISBL fuse is unprogrammed, the reset circuitry is connected to the pin, and the pin can not be used as an input pin.If PC6 is used as a reset pin, DDC6, PORTC6 and PINC6 will all read 0.PCINT14: Pin change interrupt sou
04:43 AM skz81: rce 14. The PC6 pin can serve as an external interrupt source
04:44 AM twnqx: ah, one of these fun chips
04:44 AM skz81: Also, unsure if you can use it as an OUTPUT pin at all to drive your piezzo
04:44 AM twnqx: btw, if you disable reset, you won't be able to program it in a normal way, and it will require high voltage programming
04:46 AM skz81: twnqx, why "one of those *fun* chips" ?
04:47 AM skz81: BTW, MC states something slightly different in their DS for the PU :
04:47 AM skz81: 1.1.5PC6/RESETIf the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C.If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running. The minimum pulse length is given in Table 29-11 on page 314. Shorter pulses are not ensured to
04:47 AM skz81: generate a Reset.The various special features of Port C are elaborated in ”Alternate Functions of Port C” on page 94.|
04:48 AM twnqx: because i had one of these once, disabled reset, and then was happy i had an STK500 around for HVP
04:51 AM skz81: Ha... You can't do that on all AVRs ?
04:55 AM skz81: evidlo2, for MOSI / DIG3 it seems OK to me
04:56 AM skz81: twnqx, ^ ???? (about RSTDISBL)
04:56 AM twnqx: on several, not all
04:56 AM twnqx: but almost all low pincount types
04:56 AM evidlo2: that's OK, I still have pin 2 free for the piezo
04:57 AM evidlo2: does my AREF look OK?
05:02 AM skz81: evidlo2, can't say about AREF / zener, never did that.
05:02 AM evidlo2: I've got a small 1V signal and I want better resolution, so I'm setting AREF to 1.2V
05:03 AM twnqx: may you link the schematic for me?
05:03 AM skz81: evidlo2, you didn't put a voltage regulator ? What if USB / barrel jack voltage is too high ? Because noisy, or because you have a universal power suplly still set on 9V ? Will blow your MCU...
05:03 AM evidlo2: twnqx:https://i.imgur.com/hM23vzD.png
05:04 AM evidlo2: skz81: I may be moving to micro usb
05:04 AM twnqx: don't
05:04 AM twnqx: you have 5V - 500R - Zener
05:05 AM twnqx: i'd say the resistance is far too low
05:05 AM skz81: evidlo2, mini or micro USB wont change anything about voltage protection of your MCU
05:06 AM twnqx: also, look at the data sheet - if you need something with less noise, they recommend a small ferrite between 5V and AVCC, plus a separate bypass capacitor
05:07 AM evidlo2: skz81: well nobody is going to apply 9V through microusb
05:08 AM twnqx: also, you have 1.1V internal vref - that is not good enough?
05:08 AM evidlo2: do I access that by setting fuses?
05:08 AM twnqx: i'd go for a 1.2V LDO plus a bypass capacitor anyway, 1.2V is a standard value that would be available as a small sot23-5 component
05:08 AM twnqx: the 1.1V? nah, just by selecting the right bits in adc config
05:09 AM twnqx: anyway, even with the internal 1.1V, add the standard 100nF capacitor to vref, too
05:10 AM evidlo2: in 5V mode does the ADC use whatever is on AVCC or somehow multiply the 1.1V to get a stable 5V reference
05:10 AM twnqx: http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf page 254 shows what the avcc should look like
05:10 AM twnqx: the 1.1V is internal bandgap, the ADC doesn't care much about avcc
05:11 AM twnqx: just must not deviate more than 0.3V from vcc
05:11 AM evidlo2: so what does the ADC use as a 5V reference?
05:11 AM twnqx: the separate input is for reducing noise from the digital domain
05:12 AM twnqx: it doesn't use a 5V reference - you can select betweeen external vref, internal 1.1V bandgap reference, or avcc
05:12 AM evidlo2: if I select 1.1V does that set my dynamic range to 0-1.1V?
05:12 AM twnqx: see page 257
05:12 AM twnqx: yes
05:13 AM twnqx: page 257 shows the possible references, the avcc either provides the reference, or it only provides power for the circuitry
05:13 AM twnqx: in which case the only important thing is to keep noise away, not set a particular voltage
05:18 AM evidlo2: so I guess I'll drop the zener and resistor and add a filter to avcc
05:18 AM twnqx: filter to avcc, capacitor to aref
05:18 AM twnqx: can never really have too many capacitors :P
05:19 AM twnqx: (unless your datasheet says something different *sigh*)
05:20 AM evidlo2: and I don't think I have space for a regulator on this design
05:20 AM twnqx: nah, you have
05:20 AM twnqx: with that current requirement it's sot23-5 or even sc60 for the regulator and two 0603 or 0402 caps :P
05:21 AM twnqx: or did you mean for the 5V?
05:21 AM evidlo2: yes
05:21 AM twnqx: you don't want a regulator if you power from USB unless you want 3.3V, given that 4.75V is still legit for USB
05:21 AM evidlo2: I do sort of care about AREF being correct
05:22 AM evidlo2: but a low part count is a priority for this design
05:22 AM twnqx: if you don't want to use the internal 1.1V, you'll definitely want a small LDO
05:29 AM evidlo2: how about no regulator and a 4V zener reference?
05:29 AM evidlo2: along with filtering on AVCC
05:31 AM twnqx: given that zeners are as large as regulators, i'd always use the regulator
05:31 AM twnqx: and you want the cap after the zener anyway, alone it's not stable enough
05:32 AM twnqx: in worst case, using a regulator means one extra capacitor
05:32 AM twnqx: also, zeners are anything but precise
05:32 AM twnqx: you *will* get a different voltage from what you intend
05:34 AM evidlo2: do you think 100mA regulator is enough for that whole display?
05:35 AM evidlo2: I compute 7 * (5 - 2) / 680 = 30mA for a single illuminated segment
05:36 AM evidlo2: digit*
05:37 AM twnqx: btw, you will get different brightness depending in the number you're showing with that schematic
05:37 AM twnqx: since you're using a common resistor for all LEDs
05:38 AM twnqx: roughly, the available current will be shared by all active LEDs - a 1 (2 active LEDs) will be brighter than an 8 (7 active LEDs) - assuming it's actually a LED display
05:39 AM evidlo2: I could get 2x 4 SIP resistor arrays and put the resistance on the individual segments
05:39 AM twnqx: you're going to use through hole?
05:39 AM evidlo2: https://i.imgur.com/B4zVNQZ.png
05:39 AM evidlo2: yes, this is designed to be fabricated by unskilled people
05:41 AM twnqx: ooook, that makes things more difficult and expensive
05:44 AM evidlo2: should I regulate down to 3.3 or 4V so my LDO doesn't drop out?
05:45 AM twnqx: i wouldn't use a regulator at all if powered from USB and all components work with ~4.75-5.25V
05:45 AM evidlo2: I need my ADC measurements to be within 50mV
05:45 AM twnqx: uh
05:45 AM evidlo2: or maybe 100
05:46 AM twnqx: and what range do you need?
05:48 AM twnqx: the 1.1V internal comes from a bandgap reference which is far more precise than anything you can achieve with a zener, or in many cases even a voltage regulator
05:49 AM twnqx: 50mV off of 5V would be 1/100, or about ten times the ADC resolution of 10 bit
05:50 AM twnqx: so i'd rather go with a 1% resistor divider, if you need larger voltage range, and the 1.1V internal reference
05:50 AM evidlo2: well there's two sensors I can use. one type ranges from 0.1 to 2.5V, which is what I've been using. There's another which goes from 0.1 to 0.6V which is more commonly available
05:51 AM evidlo2: I would use the internet reference when reading that one
05:51 AM evidlo2: internal*
05:52 AM twnqx: so, just add a 100nF to aref, and use that one - you have ~1mV resolution with the ADC, so you have quite some room for noise if you need 50mV
05:52 AM evidlo2: 50mV is with the 0.1 to 2.5V sensor
05:53 AM twnqx: still, you have 1.1V/1024 resolution
05:53 AM twnqx: or 1.07mV
05:57 AM evidlo2: right, but if I'm using AVCC as a reference for the 0.1-2.5V sensor, I probably want to regulate down from 4.75-5.25 to something consistent
05:57 AM twnqx: do you *need* to use that one though
05:57 AM twnqx: you will e.g. get fun with programmers - those usually run on 5V
05:58 AM twnqx: which means you might need level shifters for programming
05:58 AM evidlo2: I forgot about that
05:59 AM evidlo2: I'm starting to think maybe I'm over optimizing
06:00 AM evidlo2: because the error in the sensor itself dominates at the ranges I'm measuring: https://www.digikey.com/product-detail/en/nxp-usa-inc/MPXV5050GC6T1/568-13603-2-ND/2186550
06:01 AM evidlo2: I'm interested in the 0-5kPa range
06:01 AM evidlo2: granted, that's maximum error. The typical error may be much lower
06:01 AM twnqx: uhhh
06:02 AM twnqx: you did notice "supply voltage: 4.75-5.25V"
06:02 AM twnqx: so, you can't go below that
06:02 AM twnqx: i hope you also noticed that the output voltage is linked to the supply voltage
06:02 AM evidlo2: yes I know
06:03 AM evidlo2: maybe I'll go with no regulator and no AVCC filtering. No external reference either
06:04 AM twnqx: if you want that sensor
06:04 AM twnqx: i'd do two things
06:05 AM twnqx: a) use a voltage divider so you can measure supply volateg, bases on the 1.1V reference
06:05 AM twnqx: b) use a voltage divider to scale down that sensor's output to a measurable range
06:06 AM twnqx: i'd personally always go with the internal bandgap reference if i can't use an external reference, and USB power will vary quite a bit
06:09 AM evidlo2: the small scale sensor is already <1.1V
06:12 AM evidlo2: for the large scale sensor, I guess I could just use VCC
06:49 AM skz81: <twnqx> you don't want a regulator if you power from USB unless you want 3.3V, given that 4.75V is still legit for USB >> yes, but the barrel jack !
07:13 AM evidlo2: does my TX header need a pullup somewhere?
07:41 AM Fuchikoma_: What protocol?
08:06 AM skz81: Fuchikoma_, https://i.imgur.com/hM23vzD.png
08:06 AM skz81: Evidlo, soft UART on PD1 ?
10:11 AM Evidlo: skz81: that's the hardware TX pin
10:14 AM skz81: Evidlo, ha OK, my bad. I don't think you need a pull up
10:15 AM skz81: unsure how the RX side behaves, if it pulls the line, it's already OK
10:15 AM skz81: Else it will wait the MCU pulls it, that's maybe how it detects the other side is up
10:16 AM skz81: that even rings me a bell
10:16 AM skz81: wait a min
10:19 AM skz81: can't find it back. Unsure what protocol it was... Anyway,
10:20 AM skz81: Evidlo, if your Rx side may be powered when the MCU is not powered, you may want to pull the line up to avoid noise on Rx side
10:25 AM Fuchikoma_: I don't think SPI needs a pullup, I2C/TWI and UART do.
10:30 AM skz81: Fuchikoma_, want the MCU pull the line enough ?
10:30 AM skz81: wont*
10:30 AM Fuchikoma_: For short distances it will probably be fine
10:31 AM Fuchikoma_: Though I'm not completely sure how the pin is driven if you use the included periphrial.
10:31 AM skz81: I wont go UART for long distances tho. Will the MCU pull the line DOWN enough with long distances + ext. pullup ? Open question...
10:33 AM skz81: I never found out that a given circuit did not work without but would with.
10:33 AM Fuchikoma_: As long as the pullup isn't too weak and the total capacitance of the line isn't too high
10:33 AM skz81: UNLIKE i²c
10:33 AM skz81: Even had to be carefull with resistor values with i²c
10:34 AM Fuchikoma_: i've never had a major deal with I2C
10:34 AM Fuchikoma_: 4.7K or maybe 10K pullups and we're done
10:38 AM LeoNerd: 10k is a bit high.. I tend to do 4k7 or 2k2
10:39 AM vmt: 4k7 is pretty standard
10:44 AM skz81: interesting : https://electronics.stackexchange.com/a/1852
10:46 AM skz81: IIRC I had to change the resistor when coming from AVR/AVR comm' and replacing one of the AVR by an ESP8266
10:46 AM skz81: were too hi for the ESP
10:47 AM skz81: resistors* (value*)
10:49 AM Fuchikoma_: Too high?
10:49 AM Fuchikoma_: That's... interesting
10:50 AM Fuchikoma_: Unless they also had to up the baud rate or something? Maybe the ESP has a lot more pin capacitance
10:52 AM skz81: When I say "IIRC", given my fucked-up memory, you can doubt anything I say after ^^
10:53 AM skz81: Yes, after thinking a bit that sound strange, maybe they were too low...
10:54 AM skz81: Anyway, I spent few hours raging to figure out what was going wrong...
12:12 PM Fuchikoma_ is now known as Fuchikoma
04:10 PM evidlo2: https://i.imgur.com/n0MLn2Z.jpg
04:10 PM cehteh: corona ventilator controller?
04:11 PM evidlo2: how did you guess?
04:11 PM cehteh: pressure sensor :D
04:11 PM evidlo2: its just a monitor
11:56 PM day_ is now known as day