#avr Logs

Sep 15 2017

#avr Calendar

12:11 AM day__ is now known as daey
12:26 AM ferdna: www.zilog.com is down =\
12:26 AM rue_shop3: !
12:48 AM rue_ is now known as rue_house
02:40 AM daey: ferdna: H:/ is done ;.;
03:02 AM ferdna: daey, ?
03:14 AM daey: ferdna: you wrote that zilog is down. H:/ being our company nas :P
03:15 AM ferdna: daey, i dont get it
03:15 AM daey: done -> down
03:15 AM daey: mistyped
03:16 AM daey: but it looks like its done for good :^)
03:17 AM ferdna: hmmm
03:25 AM Emil: rue_house: wh
03:25 AM Emil: rue_house: hm?
05:30 AM DaRkV0rt3X: Hello guys
05:30 AM DaRkV0rt3X: I'm using an AtMega328P
05:30 AM DaRkV0rt3X: and I'm about to start using interrupts
05:31 AM NoHitWonder: hello
05:31 AM DaRkV0rt3X: I want to have 2 press butons attached to AtMega so that when I press any of those press buttons, an interrupt is activated and a function is executed
05:31 AM DaRkV0rt3X: which interrupt should I use?
05:31 AM DaRkV0rt3X: PCINTx or INTx?
05:32 AM NoHitWonder: i would say PCINTx, but i dont really know without looking
05:32 AM DaRkV0rt3X: I was thinking about INTx because it's an external source, no?
05:33 AM DaRkV0rt3X: I'm reading here:
05:33 AM DaRkV0rt3X: http://www.atmel.com/images/atmel-42735-8-bit-avr-microcontroller-atmega328-328p_datasheet.pdf
05:33 AM DaRkV0rt3X: Page 82
05:39 AM NoHitWonder: PCINTx are Pin Change Interrupt Requests
05:40 AM NoHitWonder: so that's what you should use
05:42 AM DaRkV0rt3X: hum, ok
05:42 AM NoHitWonder: INTx are external interrupts for example for sensors that gives an interrupt signal to the MCU when they receive data to send
05:42 AM NoHitWonder: for waking the MCU up
05:42 AM NoHitWonder: i think
05:42 AM DaRkV0rt3X: ah ok
05:42 AM DaRkV0rt3X: makes sense
05:43 AM DaRkV0rt3X: it's just that I couldn't figure that out from what the datasheet says
05:59 AM DaRkV0rt3X: NoHitWonder: do you know if you set a specific setup to the ADC, if all pins use that specific set of if it is possible to setup each ADC pin independently?
06:00 AM DaRkV0rt3X: sorry, I think I messed up typing
06:00 AM DaRkV0rt3X: NoHitWonder: do you know if you set a specific setup to the ADC, if all pins use that specific setup or if it is possible to setup each ADC pin independently?
06:01 AM DaRkV0rt3X: The reason for my question is beacause I'm alraedy using 2 ADC pins but now I need more ADC pins but running in different mode
06:05 AM NoHitWonder: i cant remember avr's ADC. and i have to do laundry now. but someone else here will help you.
06:06 AM DaRkV0rt3X: ok, thanks
06:29 AM Emil: DaRkV0rt3X: INTx of course
06:30 AM Emil: I don't see why the fuck would you use PCINTx if you can use INTx
06:30 AM Emil: NoHitWonder: do you even AVR, bro?
06:30 AM Emil: DaRkV0rt3X: you should use INTx
06:31 AM Emil: DaRkV0rt3X: you also need filtering/debouncing in any situation (unless you add a chip that does that for you)
06:31 AM Emil: preferably both in software and hardware
06:31 AM Emil: NoHitWonder: seriously I doubt your expertise here :D
06:32 AM Emil: DaRkV0rt3X: AVRs have a single channel ADC and a mux
06:32 AM Emil: so that you can select multiple inputs to your ADC
06:32 AM Emil: Very rarely must you change the ADC overall configuration when measuring multiple signals
06:32 AM DaRkV0rt3X: ok, thanks for the update
06:33 AM Emil: DaRkV0rt3X: so I don't realy understand whatcha mean with specific setup for each pin
06:33 AM DaRkV0rt3X: I was using Single Mode to read ADC0 and ADC1
06:33 AM Emil: The datasheet is clear: you configure that ADC and then when you so desire change the mux to measure another pin, keeping in mind that the first reading might be trash
06:34 AM DaRkV0rt3X: Now I want to use external interrupt source at ADC2 and ADC3
06:34 AM DaRkV0rt3X: and I'm not sure if I still can use Single Mode with interrupts or if I should change to Free Running
06:34 AM Emil: you want to trigger the ADC on external interrupt?
06:34 AM LeoNerd: PCINT is not part of the ADC module
06:34 AM Emil: LeoNerd: yes we know
06:34 AM Emil: No one said that :D
06:34 AM LeoNerd: It;s a totally different ability of the same pins
06:35 AM Emil: we know
06:35 AM LeoNerd: So I don't see where the confusion is
06:35 AM DaRkV0rt3X: Let me summarize what I have and what I'm trying to do
06:35 AM Emil: LeoNerd: if you can do multiple configs for each muxed input
06:35 AM Emil: LeoNerd: to which the answer is no
06:35 AM DaRkV0rt3X: summarise, not sure who it's written
06:35 AM DaRkV0rt3X: s/who/how
06:36 AM DaRkV0rt3X: Im reading analogue values at ADC0 and ADC1 using Single Mode
06:36 AM Emil: DaRkV0rt3X: but really, if you want to normally measure two channels and on button press measure two other channels then just do that in an interrupt?
06:37 AM DaRkV0rt3X: Now I want to add a new functionality to my program
06:37 AM Emil: What kind of sample rates and bit depths do you need for dem channels?
06:39 AM DaRkV0rt3X: I want to read the input where 2 press buttons will be connected and trigger functions when those press buttons are activated
06:39 AM DaRkV0rt3X: The reading values stuff is done and working
06:39 AM DaRkV0rt3X: at ADC0 and ADC1
06:40 AM LeoNerd: those buttons: are they digital, just high/low?
06:40 AM MrFahrenheit: I just spent about a week debugging an i2c touchpad on my new super-low-end laptop and I think I've figured it out, seems like the dedicated cypress i2c chip on it that has an ARM core doesn't implement i2c properly and requires a restart instead of a stop-start to give replies
06:40 AM LeoNerd: MrFahrenheit: many chips do indeed need restart
06:40 AM LeoNerd: I have several
06:40 AM DaRkV0rt3X: LeoNerd: yes
06:41 AM Emil: https://emil.fi/jako/koodi/pseudoadc.c
06:41 AM DaRkV0rt3X: when I press them, I just want to call a function inside an interrupt handle
06:41 AM LeoNerd: DaRkV0rt3X: OK so jyst use PCINT then. This has nothing to do with thw ADC at all
06:41 AM LeoNerd: in any way
06:41 AM Emil: Wtf
06:41 AM DaRkV0rt3X: hum, ok
06:41 AM MrFahrenheit: LeoNerd, and this one was made to work in PCs with plug and play, also, there's a possibility that it also needs the repeated start to be delayed a certain amount of us, but I still have to check that
06:41 AM LeoNerd: other than the physical pins come out the same. except you're not muxing it so you don't care
06:41 AM Emil: why the fuck are you advocating for PCINT when you can use INTx :D
06:42 AM Emil: DaRkV0rt3X: if you don't have anything else for INTx then use INTx instead of PCINT
06:42 AM LeoNerd: Emil: I don't believe there is a chip wherein ADC pins also have full INT ability
06:42 AM DaRkV0rt3X: ok guys
06:42 AM DaRkV0rt3X: thanks
06:42 AM Emil: LeoNerd: that's not what he asked :D
06:42 AM LeoNerd: I saw ADC2/3
06:43 AM Emil: LeoNerd: he has buttons and wants to trigger ADC read on button input
06:43 AM LeoNerd: I thought buttons were attached to the ADC2/3 pins?
06:43 AM Emil: No
06:43 AM Emil: They are separate things
06:43 AM LeoNerd: Ah
06:44 AM LeoNerd: Then I understand even less how it;s a confusing question
06:44 AM Emil: DaRkV0rt3X: draw a simple schematic that shows to what your buttons and connected to and what your adc is supposed to measure
06:44 AM LeoNerd: ADC, buttons; separate things, deal with them independentlu
06:44 AM LeoNerd: What even is the confusion?
06:45 AM Emil: LeoNerd: there was uncertainty about ADC configuration
06:45 AM Emil: LeoNerd: if you can have multiple configs for separate pins
06:45 AM Emil: (which would be pretty sweet)
06:46 AM LeoNerd: To solve what problem?
06:46 AM DaRkV0rt3X: ok, guys
06:46 AM Emil: LeoNerd: he's inexperienced
06:46 AM DaRkV0rt3X: I'm at work and cant read what you guys are saying continuosly
06:46 AM DaRkV0rt3X: I'm sorry
06:46 AM Emil: DaRkV0rt3X: draw a simple schematic
06:46 AM DaRkV0rt3X: the ADC stuff is done and solved
06:46 AM DaRkV0rt3X: but I think I got it now
06:47 AM DaRkV0rt3X: I was messing the interrupts stuff with the ADC
06:47 AM DaRkV0rt3X: and it's not needed
06:47 AM DaRkV0rt3X: as you guys said
06:47 AM DaRkV0rt3X: are independant things
06:47 AM DaRkV0rt3X: so no big worries
06:47 AM DaRkV0rt3X: I'll draw a schematic
06:53 AM DaRkV0rt3X: https://imgur.com/a/byT7j
06:54 AM DaRkV0rt3X: this will be what I'm thinking about to activate the interrupts
06:54 AM DaRkV0rt3X: when one button or the other is pressed, an interrupt is activated and a function will kick in
06:54 AM LeoNerd: That is the usual mechnism yes
06:54 AM LeoNerd: Often pins have internal pullups you can enable even, meaning you don't even need that external resistor
06:55 AM DaRkV0rt3X: and the function that is to be executed has, in fact, nothing to do with the ADC
06:56 AM DaRkV0rt3X: So, i don't need to change any ADC setup
06:56 AM LeoNerd: Personally, I don't really do *anything* inside interrupts other than schedule another task to be executed
06:56 AM LeoNerd: It generally leads to neater code without needing to think much about volatile or locking or whatever
06:56 AM DaRkV0rt3X: I messed up things because I was reading an interrupt driven ADC example
06:57 AM * LeoNerd nod
06:57 AM DaRkV0rt3X: LeoNerd: "schedule another task" is to call a function inside the ISR, no?
06:58 AM LeoNerd: Well,.. ish. In practice that turns out just to set a flag on a data structure somewhere then return
06:58 AM LeoNerd: It's not going to directly interact with any hardware, for example
06:58 AM DaRkV0rt3X: hum, I see
06:59 AM DaRkV0rt3X: lunch time now
07:00 AM DaRkV0rt3X: c u laterzzz
07:23 AM Emil: It depends entirely on your use case
07:23 AM Emil: avrs are very limited in their resources
07:23 AM Emil: I wish I could use them like computers but that doesn't guarantee execution time
07:23 AM Emil: And RTOSes et cetera have a lot of overhead
07:36 AM MrFahrenheit: LeoNerd, well restart didn't work... would you happen to know the name of this delay in an i2c context? https://imgur.com/a/s8q9s
07:36 AM MrFahrenheit: both images are repeated starts, and that delay is the only difference I can find between the working and not working capture
07:37 AM polprog: the delays there so the chip can prepare its output
07:38 AM MrFahrenheit: not sure how to manage that with this designware i2c controller though, it's autonomous
07:38 AM polprog: for example some digital thermo chips need a delay between measure start and read commands (in this case to get an accurate temp reading)
07:38 AM polprog: brb, off the train
07:38 AM MrFahrenheit: and the spec doesn't allow a delay, so they're just gambling that the windows driver will give them one
07:43 AM polprog: lol
07:46 AM MrFahrenheit: one could generate a delay like that by simply not filling up the fifo buffers and forcing the controller to wait, I guess, but this i2c controller also exists in a configuration where it autogenerates stop events and you don't know which version you have
07:47 AM MrFahrenheit: so it's pretty bullshit really
07:47 AM MrFahrenheit: *pretty much
08:29 AM polprog: cool grafitti on a viaduct i passed today: https://puu.sh/xAjM3/430a9fb225.jpg
08:31 AM devinmcelheran: Is there a way to associate a regular variable with a memory mapped register? I know there are the macros, but if I wanted to make a struct of memory mapped registers, do I have to use pointers, or is there another way?
08:33 AM LeoNerd: Annoyingly, gcc doesn't have an absolute positioning hint. You *might* be able to do it with a linker script
08:33 AM LeoNerd: I've often thought all the regular registers would be a lot neater done that way, because then they turn up properly in DWARF annotations and so disassembly can know their names
08:37 AM devinmcelheran: That's a shame. I'd love to be able to be like ledpin.setoutput = 1 or something more complex like the USI stuff we were talking about and just treat the entire USI thing like an object. I would normally use a pointer, but I read that 8-bit micros are terribly slow with their 16-bit pointers.
08:46 AM LeoNerd: Yah; it's a sortof neat idea but a bit more work than is easily justified. I don't really bother
08:46 AM LeoNerd: Writing little abstraction functions around the various hardware registers really isn't that hard
08:50 AM devinmcelheran: I just think that the code could be back much cleaner and understandable with structs. I'm not a fan of the way that C function names get so long without namespaces.
08:50 AM LeoNerd: On AVR I usually find a single underscore is sufficient
08:50 AM LeoNerd: e.g. i2c_read()
08:51 AM LeoNerd: Occasionally two, to separate verbs; i2c_set_clock()
08:52 AM devinmcelheran: Yeah,that's what I've been seeing, but my eyes don't seem to agree with it. Maybe it's my lack of experience with C. I've done more in Python and C++.
08:52 AM LeoNerd: So just pretend one of the _s is really a smudged out .
08:52 AM LeoNerd: i2c.set_clock
08:53 AM devinmcelheran: I'm not too worried, it's probably just my white privilege showing.
08:53 AM devinmcelheran: I'm apparently a syntaxist.
08:55 AM thardin: prefix and underscores are perfectly cromulent
08:55 AM thardin: just keep your prefix short
08:56 AM thardin: it's not like you get away from it in c++. if you have two namespaces with the same function name you still have to go nsA::foo() nsB::foo()
08:57 AM thardin: or even better, ::nsA::foo()
08:58 AM devinmcelheran: That's not as often the case as the function is a method that's called from an object anyway, though, right?
08:59 AM thardin: It Depends(tm)
09:01 AM thardin: I don't really mind the C way of doing things. I do miss RAII however
09:01 AM thardin: but on a micro you shouldn't be doing dynamic allocation most of the time
09:01 AM thardin: no account of the lack of any MMU
09:01 AM thardin: on
09:10 AM tpw_rules: memory fragmentation: its bad
09:19 AM devinmcelheran: How do you deal with applications that require dynamic memory in embedded projects?
09:19 AM devinmcelheran: Given that there's no watchman that can reclaim memory you've lost.
09:19 AM LeoNerd: So far I haven't had such a need
09:20 AM LeoNerd: I really can't think of anything that would need dynamic memory on such a device
09:20 AM devinmcelheran: Yeah, I guess everything is typically made to fit, eh?
09:20 AM devinmcelheran: And all information is ephemeral in some way, like a stream or something.
09:36 AM thardin: just preallocate however much you need. arrays of unions of structs for example
09:37 AM thardin: this could be done on PCs too. but only really done by fortran and ada/spark folks
09:42 AM devinmcelheran: By preallocate do you mean hard-coded array lengths like int x[50], or defined during config/setup before your main loop?
09:43 AM devinmcelheran: I've heard Ada is really powerful for precompile bug checking at static analyzers.
09:43 AM thardin: yeah hard coded lengths
09:43 AM devinmcelheran: Apparently the whole contract system can lead to there being mathematical proofs that there cannot be any error with a given algorithm.
09:43 AM polprog: i think it's better to use malloc for huge arrays
09:44 AM thardin: yes, ada's static checking is pretty dank
09:44 AM polprog: i never had a chance to program in ada
09:44 AM devinmcelheran: polprog, what are the differences between malloc and calloc, and whatever else there is?
09:45 AM polprog: malloc allocaes the memory, i cant tell you anything more from the top of my head :P
09:45 AM polprog: lemme find something on that
09:45 AM rue_house: The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns
09:45 AM rue_house: a pointer to the allocated memory.
09:45 AM rue_house: The malloc() function allocates size bytes and returns a pointer to the allocated memory.
09:45 AM rue_house: calloc clears the memory, malloc just gives it to you
09:46 AM polprog: http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html
09:46 AM thardin: calloc checks that nelem*size doesn't overflow
09:46 AM thardin: in addition to clearing
09:46 AM polprog: malloc, calloc, realloc
09:47 AM polprog: dont forget to free after yourself
09:47 AM rue_house: http://litux.nl/man/htmlman3/malloc.3.html
09:48 AM thardin: alloca can be quite nice
09:52 AM thardin: on more constrained platforms I tend to make great use of unions
09:55 AM devinmcelheran: What are some practical applications of unions? I've heard people praise them, but I've never seen anything more than a contrived example.
09:55 AM thardin: you can do some basic polymorphism with them
09:56 AM devinmcelheran: Well, I got that much, but it seems to me that it's so basic that's almost useless.
09:56 AM thardin: typedef struct { uint8_t a_or_b; union { struct {} a; struct {} b; } u;
09:57 AM thardin: depends on how much memory you have to spare
09:58 AM devinmcelheran: Why not maintain arrays of a and b independently?
09:58 AM thardin: depends on how much memory you have, and the size of a and b
09:59 AM devinmcelheran: Can you give me a practical situation that would call for it?
09:59 AM devinmcelheran: I know I'm overlooking something
10:00 AM devinmcelheran: I'm not trying to be argumentative, I'm genuinely curious.
10:01 AM thardin: well, as said: it's useful for memory reuse
10:01 AM thardin: if you need to do a lot of data processing in two functions, but the data doesn't have to be kept around
10:02 AM thardin: one example could be gathering lots data from ADCs, reformatting it for sending over USART, and later reusing the memory for something else
10:02 AM thardin: I may have to do something like this in a project I'm working on
10:03 AM thardin: I'd split the memory into two major parts: one for outgoing USART data and another for incoming ADC or other data
10:03 AM thardin: which is perhaps not yet an example where a union might help, I admit
10:04 AM devinmcelheran: So, like repurposing a buffer?
10:04 AM thardin: a more direct example is when writing demos for old machines, like atari vcs or NES
10:04 AM thardin: where you need to keep reusing what little memory you have for each screen
10:05 AM thardin: but yeah, repurposing. in my case I do have XMEM, but it may still happen that it's only enough for one single task at a time
11:07 AM enh: This channel is going to be 11 years old soon.
11:13 AM APic: So?
11:14 AM enh: nothing. Just a useless statement.
11:21 AM APic: Good.
11:26 AM JanC_ is now known as JanC
12:10 PM Guest88825 is now known as Emil_
12:10 PM enh: is there an avrdude equivalent to program an stm32?
12:24 PM polprog: im joining the question
12:38 PM antto: essteaemdude
12:40 PM cehteh: enh: there are dfu-util etc
12:43 PM enh: Anybody can, please, supply a script like minimal example to upload code to an STM32 using only command line stuff?
12:46 PM devinmcelheran: Take a look at what the Arduino tool uses?
12:55 PM cehteh: enh: http://dfu-util.sourceforge.net/dfu-util.1.html see EXAMPLES section
12:55 PM MrFahrenheit: why does this channel constantly get questions about stm32
12:56 PM LeoNerd: Maybe there isn't a #stm32 ?
12:57 PM cehteh: :)
12:57 PM MrFahrenheit: I'm not complaining, I'm just curious
01:30 PM Casper: MrFahrenheit: look at the topic?
01:33 PM MrFahrenheit: heh
01:34 PM MrFahrenheit: looks like the topic is as confused by it as I am
01:54 PM Casper: exactly
01:54 PM Casper: blame rue!
01:55 PM Casper: it's all rue's fault!
02:00 PM wizkid057: anyone familiar with the AT32UC3C3 ?
02:01 PM LeoNerd: One of the USB chips?
02:01 PM wizkid057: *C2
02:01 PM wizkid057: it's an automotive AVR32
02:03 PM wizkid057: having a weird issue that's got me pulling my hair out. No matter what I do the clock speed is not correct (using any of the internal sources). with the 8MHz internal clock I end up with a speed of ~10.6MHz... way beyond the error range in the datasheet
02:06 PM LeoNerd: What are you doing to measure it?
02:06 PM LeoNerd: Oh.. AVR32.. those odd beasties ;)
02:07 PM wizkid057: blinking some LEDs at 1s intervals
02:08 PM wizkid057: actually, I just tried another copy of the board with the exact same code... and it works.
02:08 PM wizkid057: maybe I've got a dud
02:08 PM wizkid057: heh
02:11 PM bss36504: I always find it interesting when the people in this channel (who i think we can assume are mostly hobbyists) manage to find single failures. The statistics on that are pretty crazy if you ask me.
02:11 PM bss36504: I just would expect a large company doing production to have an appreciable amount of failures, whereas since "our" volume is so low it seems unlikely
02:12 PM Casper: wizkid057: look up the clock calibration
02:12 PM Casper: maybe you got one that is miscalibrated, or you erased the calibration info by mistake<
02:13 PM Casper: I think it can do -50% to +200% (with some issues)
02:14 PM bss36504: Though I guess contrary to my point, I once got a whole bunch (like 100) 32U4s that had dead memory addresses
02:14 PM Casper: bss36504: I suspect the programming tools of the hobbyist are bugged and cause issues
02:14 PM Casper: like erase the signature
02:15 PM bss36504: I was using a JTAGICE3 and it consistently failed the verify step in the same way at the same address on a given part. Move to another part, different addresses. All the parts were in the same mfg lot. I had a couple left from a different lot and they worked fine.
02:16 PM bss36504: So I bought more (or rather, my company bought more) and they worked great.
02:17 PM Casper: It is also possible that they do a shitty QC for the smaller clients?
02:17 PM Casper: or maybe they send the failed batch to the smaller clients too...
02:19 PM bss36504: Idk, it's not like I was buying from a crap supplier. this was a digikey order. Digikey gladly refunded us and I sent a note to Atmel FAE, no reply.
02:19 PM bss36504: No chip producer would ever willingly send bad hardware out the door.
02:20 PM bss36504: It just reflects poorly on them. Obviously they had a silicon issue that wasnt fully checked in production. They're not going to screen every address on every part, in all likelihood they did a check inspection of a small sample of tested good parts (doing full address scan) and they were fine.
02:21 PM bss36504: Statistically the lot was clean. However, there could have been a defect on that single wafer within a lot, and the CI might not see that.
02:21 PM Emil: bss36504: it's actually more likely that discussion groups gather the statistical anomalies
02:22 PM bss36504: I never worked for atmel so I have no clue what their test protocol is, but I have worked for other semiconductor companies in test and that's what we did. You characterize a bunch of parts, run a shitload through a full production screen, then you release a pared down version of the tests to production and do check inspections along the way
02:22 PM bss36504: Emil: I disagree, even the hundreds of us in here can't match the volume of a few large companies buying product from atmel
02:22 PM wizkid057: Casper: yeah, I'm guessing it's borked
02:23 PM Emil: bss36504: you are missing a key insight here
02:23 PM Emil: bss36504: first of all, you are running into confirmation bias
02:23 PM Emil: You tend to remember the bad/interesting more than the mundane
02:23 PM Emil: secondly people tend to join discussion forums only when they have issues
02:24 PM wizkid057: I cant seem to find any data on calibrating this on the AT32UC3C2
02:24 PM Emil: AT32
02:24 PM wizkid057: only info I see in the datasheet is about reading the factory values, but not what they mean
02:24 PM bss36504: Emil: Yes, but I also worked in test, and it just seems very unlikely that the hobbyist population's consumption of product would ever match the consumption of all the large customers, who, statistically, should see more of these field failures.
02:24 PM Emil: That sounds a lot like STM32
02:25 PM Emil: Which sounds kawaii
02:25 PM Emil: bss36504: now you are stuck in a defense where a challenging viewpoint is seen as a threat ;)
02:26 PM Emil: For fabs, failures are just numbers that don't get reported but internally
02:26 PM bss36504: Oh come on now Emil, we're all friends
02:26 PM Emil: For hobbyists every single instance should work or they feel bad
02:26 PM bss36504: But I'm just speaking from a position where I've had the industry experience.
02:26 PM Emil: Not to mention that hobbyist sourcing of parts is questionable :D
02:26 PM bss36504: That is also true,
02:26 PM Emil: Where did the mcu in my minimum development board from china originate?
02:27 PM bss36504: At least in my case, Digikey should be a reputable source since most of their wares are shipped straight from the factories.
02:27 PM bss36504: At least thats how we pushed our shit through Digikey
02:27 PM Emil: All major distributors are reputable
02:27 PM Emil: Digikey, Farnell, Arrow, Mouser, TME, et cetera
02:27 PM bss36504: yeah for sure
02:28 PM Emil: And even they (rarely) run into authenticity issues :/
02:29 PM bss36504: True. I kinda doubt this was a counterfeit issue, because the parts worked if you just programmed and didnt bother with the verify step, but yes, you're right
02:29 PM bss36504: At the end of the day, my wonderment about the statistics of hobbyists vs corps seeing field failures is just that, wonderment. Doesn't really matter.
02:29 PM bss36504: didnt mean for this to be a big discussion haha. Suppose that's the nature of the channel though ;)
02:30 PM Emil: ;)
02:31 PM polprog: i find ghost shifts pretty fascinating
02:31 PM polprog: my keyboard is probably from a ghost shift
02:33 PM bss36504: polprog: ghost shift?
02:33 PM polprog: its when the factory crew decides to make an extra aundocumented run from spare material
02:33 PM polprog: undocumented*
02:33 PM wizkid057: Casper: hmm... data at 0x80800200 is all 1's... ugh
02:34 PM Casper: that's out of range
02:34 PM Casper: and the natural flash state is 1
02:34 PM wizkid057: chip is brand new... never been used until now
02:34 PM polprog: why do i think it's a ghost shift, see, the serial number scheme is known. the last letter is A, B or C indicating the shift that made it. Mine is D... :P
02:34 PM wizkid057: and nothing of mine would have overwritten that
02:36 PM wizkid057: guess that data wouldn't be saved anywhere else
04:38 PM NoHitWonder: enh https://github.com/stv0g/stm32cube-gcc
04:40 PM NoHitWonder: but i bet youre using libopencm3, right?
04:41 PM NoHitWonder: if not, take a look https://github.com/libopencm3/libopencm3
05:02 PM MrFahrenheit: don't you love it when code you didn't change breaks while you're debugging other code
05:29 PM learath: MrFahrenheit: tbh, as long as the bugs are reliable I don't mind them any more
05:29 PM learath: it's the ones I can't reproduce that kill me
05:42 PM enh: NoHitWonder: This makes sense? https://launchpad.net/gcc-arm-embedded
06:03 PM enh: MrFahrenheit: buffer overflow?
07:07 PM NoHitWonder: yes
07:18 PM enh: NoHitWonder: I found this useful. https://stackoverflow.com/questions/34993968/linking-succeeds-with-arm-none-eabi-g-but-not-arm-none-eabi-gcc It helps to define a workflow for stm32 using ony command line options
08:59 PM enh: cehteh: ?
09:00 PM enh: Or anybody else.
09:00 PM enh: If you have an mcu dedicated to controlling your servos, how would you prefer to send the servo position to it?
09:01 PM enh: Absolute timing (0 to 4096), a normalized number (float, -1 to 1) or a normalized number * 10000 ( -10000 to 10000)?
09:11 PM Lambda_Aurigae: I do it with 0-255 myself, but
09:14 PM Lambda_Aurigae: being hobby servos, that's all the resolution I really need or can really expect from them.
09:27 PM enh: The PWM controller can do 12 bits
09:28 PM enh: I want to make that transparent, though.
09:30 PM enh: I'm programming the servo control module to accept values from -10000 to 10000. The zero, max, min and pos for each servo must be within those values
09:30 PM enh: I wanted -1 to 1, but this implies using floats
09:31 PM Casper: what's wrong with float?
09:31 PM * Casper points to his float based thermostat
09:31 PM enh: oh, come on. Ask Emil.
09:31 PM Casper: float/float = 900 bytes
09:32 PM enh: When I talked about using floats here I was almost cricified
09:32 PM enh: crucified
09:32 PM Casper: same, that didn't prevented me from using it
09:33 PM Casper: but I almost ran into trouble due to it
09:33 PM Casper: 6232 bytes compiled, out of 8192
09:33 PM Casper: for a simple thermostat...
09:33 PM Casper: which I'm not fully done
09:35 PM enh: So... I banned floats from all my code
09:35 PM enh: And I have to deal with integers
09:35 PM enh: -10000 to 10000 is not so bad
09:36 PM Casper: yeah
09:37 PM Casper: when you can avoid float, avoid it
09:37 PM Casper: in my case, it was a bit hard
09:37 PM enh: I'll install a PID to change the servo position and remove position jumps
09:37 PM Casper: I need log() and 1/x
09:37 PM cehteh: enh: no float for sure :)
09:37 PM enh: You can multiply by 10000
09:37 PM Casper: try doing log without float...
09:37 PM cehteh: enh: usually value in µs 16bit fits well
09:38 PM enh: Log can be approximated by the first terms of its expansion series
09:38 PM cehteh: even when you want higher resolution (fractions of µs)
09:39 PM enh: cehteh: I would need from 16384 to 16384 to use 16 bits.
09:39 PM enh: - to+
09:39 PM Casper: temperature = 1.0 / ( (1.0/298.15) + (1.0/(float)NTCBETA) * log(( ((float)adc * (float)NTCFIXEDRES) / ((1024*16)-adc)) / (float)NTCRES) ) - 273.15;
09:39 PM cehteh: you dont need a pid for servo positioning but some speed limit and lowpass (possibly already done at your control loop) could be benefitful
09:39 PM cehteh: also you need servo trims/clamping/midpoint/expo/rate .. foo bar
09:40 PM enh: That all can be added. I'm putting a minimum
09:40 PM cehteh: enh: by value in µs i meant 500-1500
09:40 PM enh: ok
09:41 PM cehteh: maybe increse the resolution by 2 or 4
09:41 PM enh: the PCA9685 can do 4096us
09:42 PM enh: if I'm not wrong
09:42 PM cehteh: by 10 (5000-15000) would be already problematic, dont forget that you have to handle integer overflows and math with the stuff
09:42 PM * Casper should try to see how much precision he really get with 16x oversampling...
09:42 PM cehteh: i dont know that chip, but i shown you the signals some days ago, with 'pure' pwm you need way more resolution because servos have these long pauses
09:43 PM cehteh: at least the traditional 50hz signal
09:43 PM rue_house: a servos ERAL range is usually about 0.5ms to 2.5ms
09:43 PM rue_house: REAL
09:43 PM rue_house: the spec is 1-2ms
09:43 PM enh: "Each LED output has its own 12-bit resolution (4096 steps) fixed frequency individual PWM controller that operates at a programmable frequency from a typical of 24 Hz to 1526 Hz with a duty cycle that is adjustable from 0 % to 100 % to allow the LED to be set to a specific brightness value. All outputs are set to the same PWM frequency."
09:43 PM cehteh: 1.5ms
09:43 PM rue_house: my controller is still better
09:44 PM enh: Last statement is problematic
09:44 PM rue_house: I could do 88 servos on an stm32 :)
09:44 PM rue_house: I did 24 for my hexapod
09:45 PM rue_house: then someone absconded with it, its in an art gallery :/
09:45 PM rue_house: my controller has resolution stupidly above what any servo can do
09:45 PM rue_house: and its stable timing
09:45 PM cehteh: enh: https://de.wikipedia.org/wiki/Puls-Pausen-Modulation the pics there give a good overview, when you dont understand german then read the engish article
09:46 PM rue_house: http://ruemohr.org/~ircjunk/tutorials/elex/hobbyservo/servo101.html
09:46 PM enh: Thanks, cehteh. But this article is about ppm
09:47 PM enh: I send the values to the servo module via SPI
09:47 PM rue_house: mmm
09:47 PM rue_house: expensive servos
09:47 PM cehteh: but you need to generate these signals with your PWM chip
09:47 PM enh: an avr takes car of controlling the pwm chip
09:47 PM rue_house: oh your using the just over 7 bit "12 bit" controller
09:47 PM enh: i have a chennel for each servo. Each channel a pwm
09:48 PM rue_house: yea, my timing does over 11 bits
09:48 PM cehteh: for sending the values you just send 16bit thats simple and precise enough
09:48 PM cehteh: either µs directly ,,, then its unsigned
09:48 PM rue_house: nobody gets as close to real 16 bit timing as I do
09:48 PM rue_house: :P
09:48 PM cehteh: or position as in -1000 - +1000 if you prefer signed
09:49 PM enh: i used position -10000 to 10000
09:49 PM cehteh: or even -10000 - +10000 for one digit more (you hardly need that)
09:49 PM enh: -1000 to 1000 looses resolution
09:49 PM cehteh: usually servos are not so precise and need calibration anyway
09:50 PM enh: now i can set min, max and zero using this range
09:50 PM cehteh: you may want more than that
09:50 PM enh: i'll implement later
09:50 PM cehteh: ok
09:50 PM rue_house: would you like to see my code? 9600 serial, up to 32 channels on a serial bus, for the pro mini board, 8 channels
09:50 PM enh: you think a pid to handle position changes is overkill?
09:51 PM enh: can i see the board, rue_house?
09:51 PM cehteh: i dont know how you are doing that
09:51 PM rue_house: its a pro mini
09:51 PM enh: is it small?
09:51 PM rue_house: you know what a pro mini looks like right?
09:51 PM rue_house: yea, do you know what a pro mini looks like?
09:51 PM enh: stm32?
09:51 PM rue_house: no
09:51 PM rue_house: a pro mini
09:51 PM enh: like the black thing?
09:51 PM rue_house: you dont kow what a pro mini is, ok, 1 min
09:51 PM enh: yep
09:51 PM enh: arduino?
09:51 PM cehteh: i'd only do the bare minimum on the servo handler, that is hard limited endpoints, sending errors back when you exceed these
09:52 PM cehteh: and do all the other trims/midpoint/calibration on the main controller
09:52 PM rue_house: https://www.aliexpress.com/item/EYEWINK-1pcs-lot-ATMEGA328P-Pro-Mini-328-Mini-ATMEGA328-5V-16MHz-for-Arduino-5V-16M/32810156549.html
09:52 PM rue_house: https://www.aliexpress.com/item/EYEWINK-1pcs-lot-ATMEGA328P-Pro-Mini-328-Mini-ATMEGA328-5V-16MHz-for-Arduino-5V-16M/32810156549.html
09:52 PM rue_house: https://www.aliexpress.com/item/EYEWINK-1pcs-lot-ATMEGA328P-Pro-Mini-328-Mini-ATMEGA328-5V-16MHz-for-Arduino-5V-16M/32810156549.html
09:52 PM rue_house: that is a pro mini }:|
09:53 PM enh: if I set a pid on servo position, the pid will handle the change to the new position continuously
09:53 PM enh: now i remember the pro mini, rue_house
09:53 PM cehteh: you may implement some protection like a filter for very flacky signals, but be careful that you dont induce any latency by filtering there
09:53 PM enh: your controller uses one?
09:53 PM rue_house: it is one
09:53 PM cehteh: some deadband could also be useful
09:53 PM enh: hum...
09:53 PM enh: how large?
09:54 PM rue_house: do you know what the distance is between the pins on that module?
09:54 PM rue_house: 0.1"
09:55 PM enh: sorry... cehteh, how large should the dead band be?
09:55 PM _ami_: rue_house: pro mini is the one which runs at 3.3v and has m168?
09:55 PM cehteh: shoud be configureable, depends on the exact servo
09:56 PM rue_house: so its about 1.2" by 0.6" " means inches
09:56 PM rue_house: the pro mini runs a m328 at 5V
09:56 PM enh: rue_house: how can you control 88 servos with an atmega328p?
09:56 PM rue_house: no
09:56 PM _ami_: ok
09:56 PM rue_house: but you can with a stm32
09:56 PM rue_house: you can controll 33 servos with a m328
09:57 PM rue_house: and 3x 4017
09:57 PM enh: with 16 bit resolution?
09:57 PM enh: ah
09:57 PM rue_house: no, with about 11 or 12 bits
09:57 PM enh: dah
09:57 PM rue_house: the pcaxxx chip being "16 bit"" is a LIE
09:57 PM cehteh: you dont need more than 10-11 bits for a servo in reality
09:57 PM enh: it is a 12 bit
09:57 PM rue_house: you DO NOT GET 16 BNIT POSITIONING WITH THAT CHIP
09:57 PM enh: it is a 12 bit
09:57 PM cehteh: i mean resolution for positioning
09:57 PM rue_house: YOU DO NOT GET 12 BITS POSITIONING WITH A PCAXXXX
09:57 PM rue_house: want to know why!?
09:58 PM rue_house: you wont get that with that chip
09:58 PM rue_house: want to know why!?
09:58 PM cehteh: 22.5ms :)
09:58 PM rue_house: WHY DO I HAVE TO TEACH EVERYONE THIS
09:58 PM cehteh: hehe
09:58 PM rue_house: you get about 7 bits with that stupid chip
09:58 PM enh: https://www.nxp.com/products/interfaces/ic-bus/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685
09:58 PM rue_house: no, you dont get 12 bits
09:58 PM rue_house: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
09:58 PM rue_house: do what you want
09:58 PM cehteh: haha
09:58 PM Casper: hi ya furious rue!
09:59 PM cehteh: servos are NOT exactly pwm :)
09:59 PM enh: I'm ignorant and dumb. Please explain.
09:59 PM rue_house: you guys dot know enough to care!
09:59 PM rue_house: I could write an article nobody could read
09:59 PM enh: i can read
09:59 PM rue_house: it just frustrates the hell outa me that you all fall for the false adversizing
10:00 PM rue_house: its like those arduino libraries that are crap, everyone just happily plugs along with them, thinking everything is fine
10:00 PM cehteh: yes
10:00 PM enh: i still do not undestand
10:00 PM rue_house: doing things like raw streaming a wav file to a dac, headers and all
10:00 PM JanC_ is now known as JanC
10:00 PM rue_house: I know
10:00 PM rue_house: did you read the servo 101 page?
10:00 PM cehteh: i'd get a bunch of attinys to generate the servo signals
10:01 PM enh: please shine you rlight on tis admirable subject
10:01 PM rue_house: I have 2 channel code fora tiny13, but it takes in an analog voltage
10:01 PM rue_house: did you read the servo 101 page?
10:01 PM rue_house: did you read the servo 101 page?
10:01 PM rue_house: did you read the servo 101 page?
10:01 PM rue_house: did you read the servo 101 page?
10:01 PM rue_house: did you read the servo 101 page?
10:01 PM enh: not all of it
10:01 PM rue_house: ok, what is the time between servo pulses?
10:02 PM enh: ah... this is what you are talking about.
10:02 PM cehteh: there was some tiny wiith multiple 16bit counters and pwm channels iirc .. forgot which one
10:02 PM cehteh: 50hz, 20ms ...
10:02 PM rue_house: 20ms
10:02 PM rue_house: thats your 12 bits
10:02 PM rue_house: so how much time is 1 count
10:03 PM cehteh: but you want a 0.5-1.5ms pulse there :)
10:03 PM cehteh: glhf
10:03 PM rue_house: hint 12 bits is 4096
10:03 PM Casper: rue_house: did you took your medication today?
10:03 PM rue_house: the 20ms is 4096
10:03 PM cehteh: told him days ago
10:03 PM rue_house: so whats 20ms/4096
10:03 PM rue_house: so whats 20ms/4096
10:03 PM rue_house: so whats 20ms/4096
10:03 PM rue_house: so whats 20ms/4096
10:03 PM rue_house: so whats 20ms/4096
10:03 PM cehteh: calm down
10:03 PM rue_house: try to stay on track
10:03 PM Casper: rue_house: go take your medication!
10:03 PM rue_house: I'd like one other human in the workd to understand something, anything
10:03 PM rue_house: so whats 20ms/4096
10:04 PM enh: Now I do understand. Amazing. Thanks for your incredible patience!
10:04 PM enh: fuck.
10:04 PM cehteh: :)
10:04 PM rue_house: no its just worth more for you to not care
10:04 PM enh: humm...
10:04 PM rue_house: Casper, you get it dont you?
10:04 PM cehteh: enh: i tried to explain that days ago, look at how servo signals are done
10:04 PM enh: I see now.
10:05 PM enh: My brain is slow.
10:05 PM Casper: rue_house: of course, but I also know some dirty work around
10:05 PM enh: Can I shut down the PWM between control pulses?
10:05 PM rue_house: busrting the pca clock?
10:05 PM Casper: that could potentially give full 16 bits precision on avr for the pulse :D
10:05 PM rue_house: Casper, ?
10:06 PM Casper: a mix of software and hardware pwm
10:06 PM rue_house: anyhow, the world is driving me mental
10:06 PM rue_house: I have a tlc5934 I'm using on a controller
10:06 PM cehteh: you can interleave 2 timers
10:06 PM cehteh: one doing the 20ms pulse
10:06 PM Casper: find a way to make a 1ms long timer, then run your 16 bits timer over 1ms, run a 18ms timer
10:06 PM rue_house: its horrid cause it really only does the counting for ya
10:07 PM cehteh: the other the 1500µs signal
10:07 PM rue_house: but I'm using it for 0-100% pwm, not servo pulses
10:07 PM cehteh: http://public.pipapo.org/cppm_parser.png look at channel 4 ... and channel 7 is the PPM btw
10:08 PM rue_house: Casper, ouch, top value of 1?
10:08 PM rue_house: well, anyhow, I need food and sleep
10:09 PM enh: Thanks, rue_house
10:09 PM rue_house: :|
10:10 PM enh: Don't forget to eat well.
10:11 PM rue_house: oh, the W5500 + arduino is working as a webserver
10:45 PM enh: ok.
10:45 PM enh: I can set a 20ms timer on the avr
10:46 PM enh: enable the PCAxxxx output with a 500Hz freq
10:46 PM enh: disabel the output after 2ms
10:47 PM enh: supposing all channels would trigger at the same time
10:47 PM enh: I can get the 4096 bits fora all servos
10:47 PM enh: 12 bits, sorry
10:48 PM cehteh: can you generate one shot signals with the PCAxxxx?
10:48 PM cehteh: i dont know them
10:49 PM enh: at 500 hz I would have one pulse each 2ms
10:49 PM cehteh: manually stopping sux and is error prone
10:51 PM cehteh: i would look if it can done in the following way: set all output times (possibly only these which changed), then strobe it to send *one* of these signals (should stop autimatically)
10:51 PM cehteh: and repeat that every 20 or somewhat microseconds
10:51 PM cehteh: well not talking about other servo signals yet
10:52 PM cehteh: have you read about oneshot, multishot and those newfangled signals yet? :)
10:53 PM cehteh: for copters you need *at least* support the 400hz servo signals
10:53 PM cehteh: 50hz is not enough
10:54 PM cehteh: that shit will become complicated enough
10:55 PM cehteh: 400hz might be actually easier because the frame is 2500µs .. you can do plain PWM then
10:55 PM cehteh: with plenty resolution
10:55 PM enh: yep
10:55 PM cehteh: *but* when you want to mix that with other protocols like 50hz or such problems start once again
10:56 PM enh: probably not possible with this setup
10:56 PM cehteh: most modern digital servos accept 400hz
10:56 PM enh: https://www.nxp.com/products/interfaces/ic-bus/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685
10:56 PM cehteh: but analog servos dont
10:56 PM enh: page 27
10:56 PM enh: section 7.4
10:56 PM cehteh: i dont want to read that :D
10:57 PM enh: ok
10:57 PM cehteh: just be careful that you make everyhing very safe, motors starting out of nothing and cant be controlled are no fun
10:57 PM cehteh: add watchdogs and safetys
10:58 PM cehteh: i'd prolly spend half of the code alone for such stuff
10:59 PM cehteh: maybe even hardware gates or even mechanical switches to pull the signals to gnd
11:01 PM cehteh: https://oscarliang.com/dshot/
11:01 PM enh: this prototype is already built. But newer generations can have more safety features
11:01 PM cehteh: losts of resources there
11:01 PM cehteh: you should have safetys from the start on
11:01 PM cehteh: esp from the start
11:01 PM enh: The active low pin can be used to enable or disable all outputs at the same time.
11:02 PM cehteh: at least for a biggier copter
11:02 PM cehteh: those can be really dangerous
11:02 PM enh: bigger copters are for later
11:02 PM enh: I'm starting small
11:02 PM enh: and without propellers
11:02 PM cehteh: carbon props cut to the bone .. maybe even bone
11:02 PM cehteh: ok
11:03 PM enh: I have a 1 year old girl at home
11:03 PM enh: and two cats
11:03 PM cehteh: minced cats :)
11:03 PM enh: no playing with propellers near them
11:03 PM enh: So...
11:03 PM cehteh: really be careful even micro copters with 5" or smaller props can give serious injuries
11:03 PM cehteh: and i know a lot stories about 'flyaways'
11:04 PM enh: if I keep output enable enabled for only 2ms and a pwm freq of 500 hz, whtn the enable window opens I get only one pulse inside it
11:04 PM enh: with
11:05 PM enh: in principle I can get the full resolution
11:05 PM enh: ah, cehteh. The copter will be tied to the floor for a long time before really leaving it.
11:06 PM enh: no taking off before trusting the commands
11:07 PM cehteh: you need to expect the unexpected .. trusting the commands is one thing, but having a backup plan/failsafe when something unexpected like a bug happens is the other
11:08 PM cehteh: code some plausibility checks in and dont arm or shut the thing down when anything looks fishy
11:08 PM cehteh: in the most dumb/simple way you can do
11:08 PM cehteh: anything smart can be suspectible for even more bugs
11:10 PM cehteh: no signal from the controller -> shutdown, only static signal from the controller -> shut down, no pings from the controller -> shut down
11:12 PM cehteh: also watch the outputs, if they dont change, then your controll loop may be broken/locked up -> shut down
11:14 PM cehteh: malformed PID's, integer overruns, math errors may make such errors, everything goes to max
11:16 PM enh: ok
11:17 PM enh: I'll take care
11:18 PM enh: Taking all pwms to zero if no calls in a 20ms window is a good idea
11:23 PM cehteh: make it 40ms then you can miss one (but log that glitch somewhere)
11:24 PM enh: ok
11:25 PM enh: I 'll count the 20ms windows. If the counter reaches n without a call from the COM module, it shuts off
11:26 PM enh: Maybe, even, without som enterlock the PWM enable cannot go to one.
11:35 PM cehteh: esc's usually have some safetys too, on powerup they only arm when the signal is at 0
11:35 PM cehteh: and if it is above 50% or so they go into calibration mode