#avr Logs

Aug 31 2017

#avr Calendar

02:35 AM danst: I believe that using arduino rx pin to read serial data from attiny2313 wouldn't work
02:38 AM danst: would buying one of these be a good idea? https://www.avito.ru/moskva/tovary_dlya_kompyutera/usb_-_uart_ttl_preobrazovatel_785328424
02:39 AM danst: I've ended up with this https://pastebin.com/bQeRZcrE
02:39 AM danst: and all output attempts were shown as NAK in sublime text stino
02:40 AM danst: in arduino serial monitor it's just ⸮⸮⸮⸮⸮
02:44 AM polprog: i believe the problem with arduino serial is that its the same pin connected to the converter and the header.
02:44 AM polprog: on the other hand you could write an arduino program that just loops it leaving the rx and tx pins in hiz mode, and later use the converter
02:45 AM polprog: anyway, an usb converter is a lot less pain to use than that "hack"
02:46 AM danst: which is the best? CH340G / PL2303 / FTDI FT232RL DTR / CP2102 DTR ?
02:47 AM danst: also I have ZS-040 bluetooth board
02:47 AM polprog: both are ok, buy the 80 rubbles one
02:47 AM danst: maybe it can be used to read serial and program wirelessly
02:47 AM polprog: all of them do the same thing essentially
02:47 AM polprog: probably yes
03:13 AM remkooo1 is now known as remkooo
03:22 AM remkooo1 is now known as remkooo
04:39 AM noHitW_work: danst did you get your serial connection to work?
05:06 AM polprog: lab power supply came \o/
06:01 AM Haohmaru: pics or it didn't happen
06:02 AM polprog: https://puu.sh/xnZMH/15c84b4382.jpg
06:03 AM Haohmaru: okay... prodigy...
06:03 AM Haohmaru: you may pass
06:04 AM polprog: heh
06:06 AM Haohmaru: i understand why your desk is a mess.. this is the normal way
06:06 AM Haohmaru: but why do i think i see a lens in that mess?
06:08 AM Haohmaru: speaking of it.. those of you who deal with electronics - is there anyone with a desk that isn't a "mess" ? ;P~
06:08 AM polprog: lens, yeah
06:08 AM Haohmaru: evacuate it immediately
06:08 AM polprog: it's an old Zenit film camera lens, works great as a magnifier
06:09 AM polprog: good that youve noticed, it should be in the drawer not on the edge of the table
06:09 AM Haohmaru: oh.. you've sacrificed it
06:09 AM polprog: not really, i still have two other lenses and the camera
06:10 AM polprog: but nobody uses film anymore
06:10 AM Haohmaru: well.. keep it somewhere safe or it'll get scratched or fall down on the concrete floor and shatter
06:11 AM noHitW_work: just out of curiosity, how would you guys implement a driver for this chip? https://www.diodes.com/assets/Datasheets/AP3156.pdf
06:11 AM Haohmaru: i sacrificed an old russian lens from a film camera to make a pseudo-macro lens for my dslr
06:11 AM Haohmaru: but.. it has a chopped off chunk on the front.. meeh
06:12 AM polprog: that's odd, theres SDI but no clk
06:12 AM twnqx: space defense initiative?
06:13 AM polprog: how does a charge pump like that work? it charges both caps to VCC and then connects them in series?
06:13 AM LeoNerd: noHitW_work: depends on the timing requirement. Looks similarish to the way you'd write WS2812
06:16 AM LeoNerd: Oh, its timing sheet is specified in µs, not ns. Should be easy enough with even a timer interrupt or something
06:16 AM noHitW_work: i have done a bit-bang driver for it but it sucks, it might not work well with real-time OS
06:17 AM noHitW_work: used a free running timer inside stm32 to do the us delays
06:17 AM polprog: i have no idea about that but maybe hardware spi could work..., if you set the frequency right, then MISO to SDI
06:18 AM LeoNerd: That looks more work than is required
06:18 AM LeoNerd: The hardware SPI units are great for some things but not others. This doesn't look very SPI-shaped
06:18 AM polprog: i dont have much experience in this field
06:19 AM polprog: hmm
06:20 AM polprog: so it counts the faling edges.. interesting approach
06:21 AM polprog: that looks like a job for a single static variable containing the number of falling edges to be sent and a timer interrupt
06:21 AM LeoNerd: Timer unit might work. Set one in a really fast PWM mode to make pulses and genlock it to another with a wider count, to count them
06:21 AM polprog: or bitbang
06:21 AM LeoNerd: Wellsure, that works too
06:23 AM polprog: im thinking nonblocking since an RTOS was mentioned :P
06:25 AM LeoNerd: Yah; many possibilities. Depends on the requirements
06:25 AM polprog: hire someone to click a switch really fast
06:26 AM LeoNerd: Unless there's anything more awkward going on, I tend to make any sort of transmission a synchronous thing, because usually there's nothing else the CPU needs to be doing
06:26 AM LeoNerd: Receivers are usually async though
06:26 AM polprog: yeah
06:26 AM LeoNerd: Even my I²C display driver writes synchronously, for nontrivally large sized buffers
06:31 AM LeoNerd: 400kHz I²C at 9 bit transfers, leaves one byte every 360 cycles on a 16MHz CPU clock
06:32 AM LeoNerd: Borderline-debatable as to whether it's worth using an interrupt for that rate, if there's not much else for CPU to be doing
06:33 AM polprog: i should try i2c
06:33 AM polprog: in fact, i can try it just now
06:37 AM Lambda_Aurigae: polprog, i2c port expanders rock.
06:37 AM Lambda_Aurigae: I particularly like the pcf8574 and pcf8574a series.
06:37 AM polprog: that's one of reasons i wanna get that to work :D
06:37 AM polprog: sometimes 595 arent wnough
06:37 AM polprog: enough
06:37 AM LeoNerd: The 8574s are lovely :)
06:38 AM LeoNerd: I tend to use them for control panels, hang buttons and LEDs off them
06:38 AM Lambda_Aurigae: the difference between the a and non a versions is the base address.
06:38 AM Lambda_Aurigae: you can have up to 8 of each on an i2c bus...giving you 16 total...8 ports each.
06:38 AM LeoNerd: The datasheet for a 8574 doesn't mention 400kHz but I usually find it works fine there, also
06:38 AM LeoNerd: Otherwise you have to do a split bus and that's annoyingly awkward
06:39 AM Lambda_Aurigae: my first project with them was combining fleury's i2c lib and 16x2 lcd lib into one unit and driving a 16x2 lcd via i2c with an 8574.
06:40 AM Lambda_Aurigae: glub,,that was,,,,12 years ago or so.
06:40 AM LeoNerd: Mmm.. If ever I wanted to put one of those LCD modules on I²C I'd do a hybrid solution, putting the actual clock line on a dedicated GPIO
06:40 AM polprog: shit, 12 years go
06:40 AM polprog: thats much
06:40 AM LeoNerd: You can clock the data twice as fast if you don't have to do two I²C transactions just to wiggle the clock
06:41 AM Lambda_Aurigae: LeoNerd, I was doing it to cut out as much i/o pin usage as possible.
06:41 AM Lambda_Aurigae: was building a 16 servo controller on an atmega32.
06:42 AM LeoNerd: Mm.. there's a dedicated chip for that :)
06:42 AM Lambda_Aurigae: of course there is.
06:42 AM LeoNerd: I imagine, 16 PWM channels needs some curiously fun timer interrupts
06:42 AM Lambda_Aurigae: not really.
06:42 AM Lambda_Aurigae: and I didn't even use a timer
06:43 AM Lambda_Aurigae: just count through a variable and do compares with the servo step variables, causing a pulse when it hit the particular servo's step number.
06:43 AM Lambda_Aurigae: ended up getting 20 servos working on one atmega32.
06:44 AM LeoNerd: Actually, I seem to remember something odd about servos being something like 1-2ms pulse on a 16ms period
06:44 AM Lambda_Aurigae: yup.
06:44 AM LeoNerd: That's plenty of dead time, you can probably manage to do just one or two servoes at a time if you stagger them
06:44 AM Lambda_Aurigae: 1-2ms pulses and the frequency of the pulses can vary dramatically really.
06:45 AM Lambda_Aurigae: the more often you pulse them the more stable they are for holding against backforce...up to a point...
06:45 AM Lambda_Aurigae: if there's no backforce then you can pulse them just when you want to change position really.
06:45 AM Lambda_Aurigae: pulse them too fast and they get jittery...at least mine do.
06:45 AM LeoNerd: Ahh.. interesting
06:46 AM LeoNerd: I seee
06:46 AM Lambda_Aurigae: the onboard controller needs a little bit of settle time after a pulse it seems.
06:46 AM LeoNerd: Infact I suddenly wonder whether a single PWM channel + a 1:16 MUX chip might do just as well
06:46 AM LeoNerd: Or two and two 1:8s
06:46 AM Lambda_Aurigae: if you are moving a long ways, 3 or 4 pulses might be needed to get it where you want.
06:47 AM Lambda_Aurigae: hobby RC servo controllers roundrobin through the servos usually.
06:47 AM Lambda_Aurigae: they send a PPM stream.
06:47 AM Lambda_Aurigae: at least, old ones did...dunno bout the new 2.4ghz digital systems as I've not played with those.
06:48 AM Lambda_Aurigae: vex robotics first gen units just sent a simple PPM stream which was pretty much converted directly into round-robin pulses for the servos.
07:06 AM polprog: here we go again
07:13 AM Lambda_Aurigae: I didn do it!
07:13 AM Lambda_Aurigae: maybe
07:14 AM polprog: i think the isp cable i made for my dragon a long time ago might be giving up
07:14 AM polprog: because as soon as i used jumper wires it worked
08:31 AM remkooo1 is now known as remkooo
08:41 AM polprog: yay
09:40 AM JanC is now known as Guest85497
09:40 AM JanC_ is now known as JanC
10:36 AM polprog: i cant manage to make avr i2c slave device send a nack
10:53 AM kvik_: danst, yes, buying a dedicated USB-TTL serial adapter would be the way to go. buy two or more while you are at it, you will need it sooner or later. I used PL2303 genuine and chinese clones without any problems on Linux, CH340G seems to be a popular choice these days.
10:53 AM LeoNerd: I have a full set of them for comparison
10:54 AM LeoNerd: Annoyingly few of them can handle BREAK conditions, which makes most of them useless for DMX
10:56 AM polprog: what kind of a condition is it?
10:57 AM kvik_: that being said, I am not sure that your problem lies in the adapter as I can see two obvious problems in your code. first thing first, "U" is a character string and not a character constant, which means you are sending random garbage out of your UART and receive that same garbage. use 'U' for single character constants, note the single quotes and learn the difference.
11:05 AM HelloShitty: Hello
11:06 AM HelloShitty: I0ve been out for a couple of days
11:06 AM HelloShitty: Because a small health condition
11:07 AM HelloShitty: LeoNerd: you remember I was trying to setup my AtMega328P tor read analog values
11:07 AM HelloShitty: ?
11:07 AM kvik_: danst, a second problem is with the USART_Init function, which doesn't expect a baud rate as we think of it, i.e. 9600 baud, but instead expects the calculated UBRR value which you can get from the tables in the datasheet or calculate at runtime (or compile time using a macro) using the equation given in the datasheet.
11:13 AM LeoNerd: HelloShitty: I'm not sure I recall it but I could well believe it yes.. go on
11:16 AM HelloShitty: I was looking to an example code for an AtMega128
11:16 AM HelloShitty: and cnhanging the code according to the datasheet of my 328p
11:16 AM LeoNerd: OK.. I'd generally start from 328P code
11:16 AM HelloShitty: But there are some details I cannot fully understand
11:16 AM HelloShitty: http://www.avrfreaks.net/forum/tut-c-newbies-guide-avr-adc?page=all
11:16 AM LeoNerd: The ADCs seem to vary betwen them
11:17 AM HelloShitty: As you know wuite well the 328p, I guess
11:17 AM HelloShitty: I could ask you some questions and probably you could answer me by memory, no? :)
11:17 AM LeoNerd: Maybe
11:17 AM HelloShitty: ok, so I'll be looking to that link I sent you and following those steps
11:18 AM HelloShitty: I already did the prescaler setup to 125Khz
11:18 AM HelloShitty: by doing the following:
11:18 AM HelloShitty: ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
11:18 AM HelloShitty: Now, the following step, I have some questions
11:18 AM HelloShitty: which is to set the ADV reference voltage
11:19 AM HelloShitty: As far as I can understand
11:19 AM HelloShitty: there are 2 possibilities for this reference
11:19 AM HelloShitty: an internal reference of 1.1V
11:19 AM HelloShitty: right?
11:19 AM HelloShitty: and a second one which is the AREFF pin
11:19 AM HelloShitty: is this accurate?
11:19 AM polprog: yes
11:19 AM polprog: mostly
11:19 AM HelloShitty: ok
11:20 AM HelloShitty: So, the example I'm following says:
11:20 AM HelloShitty: Next, let's set the ADC reference voltage. This is controlled by the REFS bits in the ADMUX register. The following sets the reference voltage to AVCC.
11:20 AM HelloShitty: ADMUX |= (1 << REFS0);
11:20 AM polprog: just to clarify, 328p or 328pb
11:20 AM polprog: ?
11:20 AM HelloShitty: Ok, this means that this tutorial is using the internal 1.1V??? Is that it?
11:21 AM HelloShitty: AtMega328p-pu
11:21 AM HelloShitty: I think that it is what is written on the chip
11:21 AM LeoNerd: Oh I never bother memorising the lowlevel bitpatterns
11:21 AM LeoNerd: I write the code once into my HAL and then don't bother thinkig about it any more
11:22 AM LeoNerd: I'd just be calling adc_setup(...) with some parameters
11:22 AM polprog: HelloShitty: look at page 317
11:22 AM NoHitWonder: i think the Areff is tied to AVCC, so its using external
11:22 AM NoHitWonder: in that paticular case
11:22 AM polprog: it can be eithet AREF, AVCC with a cap at AREF, and internal 1.1 with a cap at AREF
11:24 AM HelloShitty: polprog: I'm at 317
11:24 AM HelloShitty: Typical Characteristics
11:24 AM polprog: the whole datasheet, not summary
11:24 AM polprog: http://www.atmel.com/Images/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf
11:25 AM HelloShitty: I'm using this:
11:25 AM HelloShitty: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
11:26 AM polprog: well, whatever, if you search for REFS youll find the table
11:27 AM polprog: LeoNerd: by the way, you do electronics profesionally?
11:27 AM LeoNerd: No idea. Define "professionally"
11:28 AM LeoNerd: I make electronics things. I sell them on tindie.
11:28 AM HelloShitty: ok polprog I saw that before
11:28 AM LeoNerd: I make *a* profit but not sufficient to do that exclusively, so I do other things as well
11:28 AM polprog: well, that's professionally imo. you get money for that
11:28 AM HelloShitty: what I need to understand is what reference is used in the tutorial so that I can say:
11:28 AM LeoNerd: OK
11:28 AM HelloShitty: ADMUX |= (1 << REFS0); <-- This means to use internal or external voltage reference
11:28 AM HelloShitty: because I can't figure that out
11:29 AM LeoNerd: The bits work in combination
11:29 AM LeoNerd: They're not singles
11:29 AM LeoNerd: REFS0 and REFS1
11:29 AM polprog: you are setting REFS0 to 1 and leaving the rest unchanged
11:29 AM LeoNerd: A two-bit field
11:29 AM polprog: better would be ADMUX |= (1<<REFS0) | (0<<REFS1)
11:29 AM HelloShitty: I understand that
11:30 AM polprog: because now you know exactly that refs1 will be 0
11:30 AM LeoNerd: Except you forgot to delete out the old set of bits
11:30 AM polprog: yeah
11:30 AM LeoNerd: ADMUX = (ADMUX & ~(_BV(REFS0)|_BV(REFS1)) | (ref << REFS0);
11:30 AM LeoNerd: is how I'd write it
11:30 AM LeoNerd: Then 'ref' can be some bit combination
11:30 AM LeoNerd: Or maybe leave the caller to bitshift it up
11:30 AM polprog: like 2 or 3 in this case
11:31 AM HelloShitty: ok, so what means V_ref turned off in option 00 in table 28-3?
11:31 AM LeoNerd: Letting the caller shift might seem simpler at first, but then some of the more complex bitflags of some peripherals are split across multiple control registers
11:31 AM LeoNerd: So I like to have the caller pass in zero-based unshifted values
11:31 AM HelloShitty: Or better
11:31 AM LeoNerd: (Eg. WGM0 to 3 bits of the 16bit timers)
11:32 AM LeoNerd: polprog: Whyso you ask anyway?
11:32 AM HelloShitty: If I connect AVCC and AREF pins to 5V and place a capacitor between AREF and GND, which option should I use?
11:32 AM polprog: LeoNerd: just curious
11:32 AM LeoNerd: External
11:32 AM HelloShitty: Is it 0 1?
11:32 AM LeoNerd: Because you're applying external power
11:33 AM LeoNerd: But why bother? There's already a setting for that - you can ask it to use AVCC
11:33 AM LeoNerd: So there's never a valid reason for tying AREF onto AVCC
11:33 AM LeoNerd: If you wanted the ADC's reference to be AVCC you can program that in software
11:33 AM LeoNerd: The AREF pin is provided in case you want to apply a more accurate external reference chip of some kind
11:33 AM LeoNerd: Then it would be derived from, and necessarily lower than, AVCC
11:34 AM HelloShitty: ok
11:34 AM HelloShitty: so
11:34 AM HelloShitty: I'm still not 100% sure about this
11:34 AM HelloShitty: If I connect AVCC and AREF to +5V, still makes sense to use a cap between AREF and GND?
11:35 AM LeoNerd: Possibly?
11:35 AM HelloShitty: Clearify please?
11:35 AM LeoNerd: If it was close enough
11:35 AM HelloShitty: Is this case the 0 1 case of table 28-3?
11:36 AM LeoNerd: But now you're on the edges of analogdesign questions
11:36 AM LeoNerd: I forget the numbers
11:36 AM LeoNerd: Stop telling me numbers
11:36 AM polprog: and that's an interesting but long ride
11:36 AM HelloShitty: I ca't get a solid answer
11:37 AM HelloShitty: so I can't understand it 100% neither make my mind about the setup
11:37 AM NoHitWonder: yes , 01
11:37 AM HelloShitty: And as I'm starting with this, I have no knowledge to decide if it's better the internal reference or the external reference or if it's good or not to use capacitors
11:38 AM HelloShitty: etc
11:38 AM NoHitWonder: is the case witth the tutorial
11:38 AM HelloShitty: ok, so thi step I think it's done
11:39 AM HelloShitty: NoHitWonder: yes, I'm following the tutorial the closest I can
11:39 AM HelloShitty: but there are always possible changes because I'm using different uC
11:39 AM polprog: how different
11:41 AM HelloShitty: some registers are different I guess
11:41 AM NoHitWonder: 128 vs 32p
11:41 AM NoHitWonder: 328p
11:41 AM HelloShitty: For instance, I can't find the description for bit ADFR
11:42 AM HelloShitty: In any of the datasheets posted here
11:42 AM HelloShitty: are descriptions for this bit
11:42 AM HelloShitty: only at page 306
11:42 AM polprog: Control F
11:43 AM HelloShitty: I can see ADFR in an image
11:43 AM HelloShitty: I have used that polprog , I'm not that retarded, lol
11:43 AM HelloShitty: I can only find one result at page 306 as I just said
11:43 AM HelloShitty: and it's on an image, not description or anything
11:44 AM HelloShitty: That was another thing I wanted to talk about
11:44 AM HelloShitty: but still not there yet
11:44 AM LeoNerd: What are you ytrying to measure?
11:44 AM HelloShitty: in fact, it was the next step
11:44 AM LeoNerd: The options exist because different things can do different things
11:44 AM LeoNerd: You haven't told us the problem you're tryoing to solve, so we can't help you solve it
11:45 AM HelloShitty: I'm building a basic antenna analyser
11:45 AM polprog: so were getting out of the XY problem
11:45 AM HelloShitty: and I need to measure the output of an OpAmp
11:45 AM LeoNerd: OK. Is the internal reference good enough for you?
11:45 AM Emil: >antenna analyser
11:45 AM Emil: >Using abr
11:46 AM Emil: avr*
11:46 AM Emil: top kek
11:46 AM LeoNerd: Basically: you use the internal one if it's good enough, and an external one if it isn't so you have to supply a better one
11:46 AM LeoNerd: That's the reasoning
11:46 AM LeoNerd: Pick one then the bitsettings should become obvious
11:46 AM polprog: but first you need to build a better one
11:46 AM polprog: or use a ready made IC
11:46 AM Emil: The internal 1.1v bandgap is fine
11:46 AM LeoNerd: Wellsure
11:47 AM HelloShitty: I'm building it, so it's out of question to buy a ready one... Where would be the fun?
11:47 AM LeoNerd: ??
11:47 AM HelloShitty: I'm trying to build a basic one based one this:
11:47 AM polprog: just to clarify i meant that there are ready made IC reference voltage chips
11:47 AM HelloShitty: http://www.hamstack.com/hs_projects/k6bez_antenna_analyzer.pdf
11:47 AM HelloShitty: ah ok, sorry LeoNerd
11:48 AM HelloShitty: sorry polprog I mean
11:48 AM HelloShitty: LeoNerd: about choosing between one or another
11:48 AM HelloShitty: I can't also answer to that
11:48 AM LeoNerd: Right
11:48 AM LeoNerd: So *that* is your problem
11:48 AM LeoNerd: Ignore putting numbers into registers right now
11:48 AM HelloShitty: because I don't know what for the AREF is used for
11:49 AM LeoNerd: Numbers in registers comes when you know *what* you want the chip to do
11:49 AM HelloShitty: or better
11:49 AM polprog: i feel bad that i have no idea how to solve that resistor bridge on the 3rd slide
11:49 AM LeoNerd: AREF is for supplying an external reference
11:49 AM HelloShitty: why one can be good for one application and not good pfr another application
11:49 AM LeoNerd: Do you need to apply an external reference?
11:49 AM LeoNerd: E.g. do you need to measure values that are larger than 1.1V? If so, then you can't use internal 1.1V bandgap
11:49 AM LeoNerd: Do you need to meaasure values with more *accuracy* than that guarnateed by the internal 1.1V bandgap? If so, then yes you can't use it
11:49 AM polprog: wait, so it's an SWR meter?
11:50 AM Emil: polprog: calculate total resistance and then divide current accordingly
11:50 AM HelloShitty: kind of polprog
11:50 AM Emil: polprog: then just juse ohms law
11:50 AM LeoNerd: Do you need to measure values with more accuracy than your power supply is guaranteed to? If yes, then you can't use AVCC either
11:50 AM polprog: Emil: thx
11:50 AM HelloShitty: hum, deppends on the OpAmps amplification, I gess
11:50 AM LeoNerd: If the situation is such that for your purpose you can't use the internal 1.1V ref, nor can you use AVCC, then yes you'll have to supply some other reference value on AREF and ask the chip to use that
11:51 AM LeoNerd: But I know of *ABSOLUTELY NO* reason you ever need to tie AREF to AVCC
11:51 AM polprog: odd, i always did that
11:51 AM HelloShitty: me too
11:51 AM polprog: whatever
11:51 AM LeoNerd: Totally random example: You want to measure signals up to 3V accurately, but you can't guarantee how good (A)VCC is going to be because of battery power
11:51 AM HelloShitty: The voltages that the AD9850 puts out are quite low
11:52 AM LeoNerd: Possibly answer: apply a 4.096V reference to AREF
11:52 AM LeoNerd: ^-- an example situation in which you *would* use AREF
11:52 AM Emil: polprog: don't
11:52 AM Emil: polprog: ever
11:52 AM Emil: polprog: tie
11:52 AM Emil: polprog: AREF to VCC
11:52 AM LeoNerd: ^-- this
11:52 AM polprog: why
11:52 AM Emil: polprog: rtfm :D
11:52 AM LeoNerd: Not only is it not necessary, in some situations it can be damaging
11:52 AM Emil: it explains it clearly
11:52 AM polprog: ill see then :P
11:53 AM LeoNerd: If you set the ADC REF mux to use bandgap, then it presents the 1.1V reference as a sortof output on the AREF pin
11:53 AM LeoNerd: So if you've just shorted that to VCC you'll cook it
11:53 AM polprog: wait
11:53 AM polprog: actually i dont
11:53 AM polprog: i was afraid that i have to submit another bloody revision
11:53 AM polprog: but it's done according to the FM.
11:53 AM polprog: cap at aref
11:53 AM LeoNerd: Cap between AREF and GND is fine, yes
11:53 AM polprog: and reference from AVCC
11:53 AM Emil: polprog: the only thing you should put on AREF is a cap or a precise voltage reference
11:53 AM polprog: :D
11:53 AM LeoNerd: It can remove some of the switching noise
11:54 AM Emil: There _should_ be a cap from AREF to GND
11:54 AM polprog: it's even in the datasheet
11:54 AM Emil: yeah
11:54 AM polprog: fuck yeah!
11:55 AM HelloShitty: Ok, so in this case I should measure the output voltage of the OpAmmp and check if 1.21V is enough, no?
11:55 AM Emil: https://emil.fi/jako/kuvat/2017-08-31_19-24-14_SS7faPoc.png
11:55 AM HelloShitty: 1.1V, sorry
11:55 AM Emil: Hooooly shit
11:55 AM polprog: kek
11:55 AM Emil: The total cost of that project just wet down 33 dollaroos :D
11:55 AM polprog: that's what happens when you just draw the whole arduino on the schem
11:55 AM Emil: Also
11:55 AM Emil: >Vector board
11:55 AM Emil: 4 dollaroos
11:56 AM Emil: all my wat
11:56 AM Emil: buy like 10 for 1 dollar on ebay
11:56 AM HelloShitty: Guys, I am already lost in the discussion
11:56 AM LeoNerd: HelloShitty: Yes; first question to ask is what is the range of your signal
11:57 AM HelloShitty: I can't decide if I should hook up AREF to AVCC and cap AREF to GND, or if I should use 1.1V internal reference
11:57 AM polprog: There's a shop in warsaw that shall not be named which sells electronic kits and stuff at crazy prices. 50 groszy per resistor (that's 0.13 bucks)
11:57 AM Emil: I should design electronics for HAMs
11:57 AM Emil: apparently they pay
11:57 AM Emil: quite wel
11:57 AM Emil: l
11:57 AM LeoNerd: Eh.. but then radio
11:57 AM polprog: you should design electronics for arduinos
11:57 AM LeoNerd: and meh
11:57 AM polprog: THEY pay
11:57 AM Emil: polprog: true dat
11:58 AM HelloShitty: LeoNerd: that voltage is the one which is going to be red by the analog input of mega328p, right?
11:58 AM HelloShitty: the voltage range you're asking?
11:58 AM polprog: what range of voltages you wanna measure
11:58 AM Emil: HelloShitty: do_not_tie_anything_to_AREF_but_a_capacitor_to_ground
11:58 AM LeoNerd: HelloShitty: yes
11:59 AM HelloShitty: Emil: but in that case I'll be using the 1.1V internal reference, yes?
11:59 AM Emil: HelloShitty: if you read the manual
11:59 AM polprog: polprog.net/rtfm
11:59 AM Emil: HelloShitty: it explains clearly
11:59 AM HelloShitty: and LeoNerd I think that will depends on the antenna being tested
11:59 AM Emil: HelloShitty: that you can select between a multitude of different sources
11:59 AM Emil: internally
11:59 AM HelloShitty: Emil: I already read the manual and it's not clear to me
12:00 PM HelloShitty: I know, I read that already
12:00 PM HelloShitty: but it is not quite clear to me
12:00 PM Emil: HelloShitty: you only need to read the bloody register descriptions to know it :D
12:00 PM HelloShitty: It's the 1st time I'm using an ADC
12:00 PM polprog: and remember to clamp that input in case some extremely high voltage is gonna appear there
12:00 PM LeoNerd: GAHHHH
12:00 PM LeoNerd: Lets start from the beginning
12:00 PM Emil: polprog: POLPROG YOU FUCKING COPYCAT :DDDDDDDDD
12:00 PM HelloShitty: Emil: I which
12:00 PM HelloShitty: whish
12:00 PM polprog: Emil: what?
12:00 PM Emil: polprog: dat spinning rtfm
12:00 PM LeoNerd: ADCs measure an analog value, and give you a number between zero and (max int for the bitsize) for that analog value *RELATIVE TO THE REFERENCE*
12:01 PM polprog: Emil: i shown you that before, it's up for like 3 month
12:01 PM LeoNerd: So it's up to you to pick a reference that will be sure to fit any value you want to measure, and / or scale your measurement input to fit the reference you have
12:01 PM Emil: polprog: I know
12:01 PM LeoNerd: How is this a hard concept ot understand??
12:01 PM Emil: polprog: also dat quote <3
12:01 PM polprog: Emil: <3
12:01 PM LeoNerd: If you're measuring a value larger than 1.1V then you can't use a 1.1V reference for it, because then you can't judge how big it is
12:01 PM LeoNerd: This is hardly rocket science
12:01 PM HelloShitty: ok, I need to take a break... My health condition don't allow me to sit in front of a computer for too long
12:02 PM HelloShitty: be back later
12:02 PM Emil: Cya
12:02 PM kvik_: I would suggest you use the simplest option first
12:02 PM kvik_: that always works
12:04 PM polprog: if it's an SWR meter he'll have to measure AC voltage at a relatively high frequency (couple hundred khz to couple hundred mhz)
12:04 PM polprog: so it's not a good project for a beginner
12:04 PM polprog: i dont think i could manage to do that
12:04 PM polprog: i would first try to chnage the amplitude of that AC voltage to a DC voltage.
12:04 PM Emil: polprog: well it depends
12:04 PM LeoNerd: Yah this is why radio stuff is always awkward
12:05 PM Emil: polprog: if you rectify and low pass you can measure it at a lower freq, too
12:05 PM LeoNerd: But then you're measuring average, and not true RMS
12:05 PM Emil: But that brings out a bunch of problems on its own
12:05 PM Emil: LeoNerd: hardly matters
12:05 PM LeoNerd: Which might matter
12:05 PM polprog: it's not that radio stuff is awkward, it's just that digital electronics is simple
12:06 PM polprog: https://www.gully.org/~mackys/miscpix/WidlarPosterForDigitalGuys.jpg
12:06 PM Emil: LeoNerd: just use a conversion function
12:06 PM LeoNerd: Only if you know the power factor
12:06 PM LeoNerd: Which means only if you know it's definitely a true sine wave
12:06 PM Emil: LeoNerd: Well I mean :D
12:06 PM LeoNerd: *actual* trueRMS conversion circuits, in analog, actually do the RMS conversion directly in hardware
12:07 PM LeoNerd: They're not too hard to build for moderate frequencies, up into the maybe hundreds of kHz, but not so much for radio frequency
12:07 PM Emil: polprog: that's a huge scan
12:07 PM Emil: polprog: fucking a
12:07 PM Emil: polprog: I'll print dat and replace the old one we have :D
12:07 PM polprog: the old poster?
12:07 PM polprog: same or different?
12:07 PM Emil: same but lower res
12:08 PM polprog: i have some posters i need to hang, but i dont wanna tape them to the wall
12:08 PM polprog: one from a local retro gaming con
12:08 PM polprog: ill show you
12:10 PM polprog: https://puu.sh/xobX9/0e63278081.jpg
12:17 PM Emil: It's sideways
12:17 PM Emil: gah
12:17 PM polprog: :/
12:20 PM Emil: That's a pretty nice picture
12:21 PM polprog: yeah, i like it
01:58 PM HelloShitty: Guys, I'm back for a bit more
01:58 PM LeoNerd: Joy for us
01:58 PM HelloShitty: I read the above conversation
01:58 PM LeoNerd: :)
01:59 PM HelloShitty: I smell sarcastic but I'm usued to it
01:59 PM LeoNerd: *ahem*
01:59 PM LeoNerd: What's up with freenode today?
02:00 PM HelloShitty: I wanted to clear my questions about the AREF and AVCC matter
02:00 PM HelloShitty: I'm good so far
02:00 PM HelloShitty: with freenode
02:00 PM HelloShitty: I'm using a dedicated server though
02:00 PM HelloShitty: Anyway
02:01 PM HelloShitty: If I connect ACVV to V and just place a cap between AREF and GND, wihout hooking up AREF to AVCC, which reference am I using?
02:01 PM polprog: whichever youve set in the register :P
02:01 PM polprog: you want to use AVcc as the reference then
02:02 PM LeoNerd: Well, that or internal 1V1. Either is fine in that scenario
02:02 PM HelloShitty: meaning V, right?
02:02 PM HelloShitty: 5v
02:02 PM LeoNerd: Meaning, whatever is at VCC
02:02 PM LeoNerd: Be it 5V or 3.3V or anywhere inbetween
02:02 PM LeoNerd: Just board power
02:02 PM HelloShitty: ok
02:02 PM LeoNerd: This is why you might want to use the internal 1.1V ref in some scenario, if VCC isn't reliable enough to be some particularly accurate level
02:03 PM HelloShitty: So, in this scenario,which option should I use from the datasheet?
02:03 PM LeoNerd: Int 1V1, or AVCC. Either works. Depends on other factors at that point
02:03 PM LeoNerd: Grr
02:03 PM LeoNerd: Anyhow - I was about to say: you're looking at this backwards
02:04 PM polprog: this is the classic XY problem
02:04 PM LeoNerd: *First* determine the properties of the signal you're trying to measure, and thus what you'll need from the ADC
02:04 PM LeoNerd: Having done that, *second* work out how to configure the ADC to do what you need
02:04 PM polprog: youre not asking for a solution, instead youre asking if a small part of the solution is OK
02:04 PM LeoNerd: But for now stop focusing on the ADC itself until we've worked out the actual problem
02:06 PM HelloShitty: ok, I'm going to try to figure that out
02:06 PM polprog: it may turn out that your ADC in the AVR part is all state of the art but you cant use it because the signals you wanna measure are just out of spec. like negative. or too big or too small!
02:07 PM polprog: if it turns out you need to shift the signals with a differential amp, *that* will be a problem! ADC is as simple as flipping some bits in some registers
02:08 PM polprog: i should take a walk, im sittin at the workshop desk all day :D
02:13 PM NoHitWonder: http://www.hamstack.com/hs_projects/k6bez_antenna_analyzer.pdf there's a schematic in this file
02:14 PM NoHitWonder: are you gonna use those same components?
02:14 PM NoHitWonder: arduino board etc
02:31 PM polprog: heh, now i get that Wheatstone bridge
02:31 PM polprog: it's easier than it looks like
05:07 PM hetii: Hi :0
05:08 PM hetii: I have such code that I run on atmega8: while(1){ if (test++ >= F_CPU){ test=0; printf("foo\n") } }
05:10 PM hetii: so I expect that my print will be called on each second but its printed on every 6th second... is it normal?
05:10 PM Casper: normal
05:10 PM Casper: your code is 100% broken
05:10 PM hetii: why ?
05:11 PM Casper: do you really think it take 1 cycle to execute the addition + comparison + jump?
05:11 PM hetii: I can image that not but didn`t expect such overload.
05:11 PM Casper: at a bare minimum each instruction is 1 cycle
05:11 PM Casper: can't go bellow that
05:12 PM Casper: you are asking atleast 3 instructions
05:12 PM Casper: and a jump is 2-4 cycles
05:12 PM hetii: ok clear, then
05:13 PM Casper: also, if you use interrupt it will not work preciselly
05:13 PM polprog: just use a timer interrupt
05:13 PM polprog: you can fine tune it
05:14 PM Casper: on my fridge controller I used interrupt for time keeping
05:14 PM Casper: did it the dirty way
05:14 PM polprog: the only thing that would be more precise than a timer interrupt is an RTC with a goo dcrystal
05:15 PM hetii: I don`t know why but each time when I try use more timers then one have some issue and result that are not correct..
05:15 PM hetii: Its frustrating.
05:16 PM polprog: youre just doing something wrong
05:16 PM Casper: volatile uint32_t secs = 0, cycle = 0; in the timer overflow vector: cycles += timerOverflowValue (usually 256 or 65536) * prescaller; if cycles >= F_CPU then cycles - F_CPU; sec++;
05:16 PM polprog: i also had terrible problems with interrupts...
05:16 PM polprog: but one day i sat and calculated every value i need, basing on the datasheet
05:16 PM polprog: and now it's easy!
05:17 PM Casper: also, if you use multi-bytes global variable that are updated in the interrupt, you need to be carefull when you access them
05:17 PM polprog: yeah, that's why you use prescalers
05:17 PM Casper: since it is a multi-bytes it is also a multi-instructions
05:17 PM polprog: anyway, night!
05:18 PM Casper: a 16 bits could be read like this: read high, interrupt fire and update the high and low and return, read new low and surprise! corrupt data that you have lots of headache to fix
05:18 PM Casper: hint: atomic block
05:18 PM Casper: nite polprog
05:18 PM hetii: night polprog :)
05:18 PM Casper: atomic block can read the interrupt, save the state, disable interrupt, then execute the code, restore the state
05:19 PM Casper: it do delay the interrupt, but safeguard against the corruption
05:19 PM Casper: brb
06:09 PM hetii: how I hate it...
06:09 PM hetii: F**@!*
06:11 PM hetii: Imagine that, I have a odroid xu4 (arm based pc) that is used to reflash esp8266, and when I drive fan, i`m not able to reflash it. Also all my uarts connected to odroid start acting odd...
06:29 PM Emil: On AVR
06:29 PM Emil: hmm
06:30 PM Emil: Yeah
06:30 PM Emil: You must do it application side and just access it atomically
06:30 PM Emil: Then you can update the time async since you are guaranteed to only be updating when access doesn't happen
07:31 PM hetii: Emil, I have such code: https://pastebin.com/FcU9Q8M5
07:32 PM hetii: where I have software pwm and read temperature from ds18b20
07:33 PM hetii: the point is when I run rainbow effect, and read temperature leds blink
07:33 PM hetii: any idea how to eliminate this effect
07:34 PM HighInBC: I like the ds18b20
07:34 PM HighInBC: easy to use and cheap
07:49 PM hetii: I found reason why it blink, lib for 1wire use cli() while reading or writting to the bus.
07:54 PM HighInBC: that makes sense
07:54 PM comptroller: I am struggling to use the XDMAC on a SAME70 processor. Does anyone on this channel have any experience with this?
07:56 PM comptroller: I am trying to get a SPI DMA transfer to work. I am working off of the example provided by atmel, and the biggest question that I have now is what would trigger a transfer
07:58 PM _ami_: comptroller, is it possible to do in atmel avrs?
07:59 PM _ami_: oh, in XMegas
08:10 PM comptroller: yeah I think xmegas have the same dma controller
08:17 PM rue_house: hey all
08:17 PM rue_house: were just gonna do a dead wood cleanup in the channel
08:17 PM rue_house: we think
08:17 PM rue_house: you might get kicked, its not personal
08:18 PM rue_house: just come back
08:18 PM rue_house: your all welcome to be here
08:18 PM enh: bots do not come back automagically?
08:18 PM rue_house: sometimes they do, sometimes not
08:18 PM Tom_L: rue just likes makin me do extra work
08:18 PM enh: kick me first, rue_house.
08:19 PM -!- #avr mode set to +o by ChanServ
08:19 PM rue_house: but there are a lot of people with the channel just left open that dotn need to
08:19 PM hetii: I Will go sleep for a while so... :)
08:19 PM Tom_L: feel better?
08:19 PM enh: yep
08:19 PM enh: I'm preparing some bread
08:19 PM enh: Dunno when I'll be back in front of the computer
08:20 PM hetii: before I go one question more, how do you think, what kind of temperature is safe in closed box with psu?
08:21 PM rue_house: about 210c, after that, the solder melts
08:21 PM hetii: huh
08:21 PM enh: < 85 degrees for most components, or not?
08:21 PM enh: celsius
08:22 PM hetii: usually capacitors have that value or 105
08:22 PM hetii: but you know, I don`t plan to stress my components.
08:23 PM enh: Talk to them. Ask how they feel
08:23 PM hetii: as I check now I have 42 degrees but its opened
08:24 PM enh: I believe there will be less than 10 people here after all the kicking
08:24 PM Tom_L: maybe
08:24 PM enh: s
08:25 PM Tom_L: we could vote on it but only a few would respond
08:25 PM Tom_L: that's somewhat the purpose of doing it
08:25 PM rue_house: irc channels have a life cycle
08:25 PM Tom_L: those that come back wanna be here
08:25 PM rue_house: somehow, a mass kick prolongs it
08:25 PM hetii: like me :)
08:25 PM rue_house: not 100% on how it works
08:25 PM Tom_L: ok well don't be offended, just come back...
08:25 PM Tom_L: mkay?
08:26 PM rue_house: were the ops
08:26 PM enh: sure
08:26 PM rue_house: pushes the buttons!
08:26 PM hetii: sure, have fun I go sleep :)
08:26 PM hetii: ok will wait a bit to see how fast you kick all of us :)
08:27 PM enh: I'm curious too
08:27 PM rue_house: its a new command
08:27 PM rue_house: were learning
08:27 PM enh: /kickall
08:27 PM rue_house: our test is complete for today, thankyou for your participation
08:27 PM rue_house: :)
08:27 PM enh: :)
08:28 PM rue_house: [ok, it didn't work, :P ]
08:28 PM hetii: Hmm
08:28 PM enh: happens
08:28 PM Tom_L: this has been a test of the emergency irc broadcast
08:28 PM Tom_L: hope you all are safe
08:28 PM Tom_L: this has been a test
08:28 PM rue_house: :)
08:28 PM rue_house: had this been a real kick you would need to rejion the channel
08:28 PM rue_house: ROFL
08:28 PM enh: I 'm ready!
08:29 PM hetii: Well even my irc clien (Xchat) have mass kickoff option
08:29 PM hetii: :)
08:29 PM rue_house: tom, we will have to figure out where the loose wire is from that buton...
08:30 PM rue_house: so, I buy an arduino uno for less than $3usd
08:30 PM -!- #avr mode set to -o by Tom_L
08:30 PM rue_house: I got a flyer from a 'local' electronics shop, $19cad
08:30 PM rue_house: ... !?
08:30 PM rue_house: they would take more than 9 days to get me one
08:31 PM Tom_L: somebody here paid me with a canadian check the other day
08:31 PM Tom_L: the bank wanted $30 to process it
08:33 PM rue_house: !?
08:33 PM Tom_L: i sent it back to them
08:34 PM rue_house: yea
08:34 PM Tom_L: ok you've distracted me enough for one night
08:34 PM rue_house: hah
08:34 PM rue_house: :)) I got 3 arduino UNOs
08:35 PM _ami_: rue_house, wow! 3 UNOs. thats too much :P
08:36 PM _ami_: i got bored with 1 uno very soon.
08:43 PM _ami_: comptroller, oh, you are trying this on one of arm atmel chips?
08:43 PM _ami_: SAMD?
08:45 PM rue_house: I got 5, iirc
08:59 PM enh: Bread is in the oven
08:59 PM enh: german like. Packed with seeds.
09:03 PM HighInBC: nice
09:04 PM HighInBC: bread in North America is a sick joke
09:04 PM HighInBC: big fan of proper bread
09:04 PM enh: The output of avr-objdump is a thing with such a mystical nature...
09:05 PM enh: HighInBC: Get a basic german recipe and start modifying it slowly
09:05 PM enh: mine uses no egg or milk
09:05 PM enh: it is a one hour preparation, half an hour waiting and one hour in the oven.
09:19 PM comptroller: _ami_, I'm working with the same70 chip
09:56 PM _ami_: comptroller, is it arm cm3?
09:57 PM _ami_: comptroller, i have used DMA on stm32 chips recently. In stm32, the medium density chips have one DMA with 7 channels. and each channel has defined events which enables the DMA action on that channel.
09:58 PM _ami_: e.g. for DMA1@channel1, i get dma event on TIM1_UP
09:59 PM _ami_: so i enable timer and enable DMA request enable on that timer1 and generate the timer1 event to facilate dma transfer
09:59 PM _ami_: i did that for GPIO write on DMA
10:14 PM _ami_: DMA mem2mem is software controlled so no need of any event to facilate it..
11:49 PM day__ is now known as daey