#avr Logs

Nov 19 2019

#avr Calendar

01:09 AM tecdroid: any hints on avr ram issues? i have a program (avr-gcc) in which some variables are set but are reading 0 after.. local function vars..
01:14 AM polprog: globa vars?
01:14 AM polprog: global*
01:14 AM cehteh: can you pastebin your code?
01:14 AM cehteh: prolly just some stupid bug
01:14 AM cehteh: if (x=0) {...?
01:17 AM tecdroid: thats where my error occours https://paste.ofcode.org/398WCrSV9D4ucfuLMF3eU8N
01:17 AM tecdroid: can_t is the struct of avr-can-lib
01:17 AM tecdroid: speed is always zero
01:18 AM tecdroid: even if i try to mock it by setting it to a value
01:18 AM cehteh: wtf casting macros
01:19 AM cehteh: ah that deserializes?
01:19 AM tecdroid: yes
01:19 AM cehteh: and thats the error? :)
01:19 AM cehteh: write those as functions
01:20 AM tecdroid: i can try
01:22 AM cehteh: i think you have some type errors there int is 16bit on avr's (prolly you want to use unsingned anyway?) but shifting a int by more than 16 positions leaves nothing, even when you cast it to 32 bit afterward :D
01:22 AM tecdroid: but to_int32 works
01:22 AM tecdroid: btw
01:22 AM cehteh: with what input?
01:22 AM cehteh: thats char* ?
01:23 AM tecdroid: 00,31,00,00,10,04,01,80,01,80
01:23 AM cehteh: anyway write that as functions, prolly static inline, the compiler may even optimize that better
01:23 AM tecdroid: ignore first two
01:23 AM tecdroid: i'll try
01:24 AM cehteh: possibly i'd even give a
01:24 AM cehteh: reference where to deserialize
01:24 AM cehteh: into temp vars rather than returning a result
01:28 AM cehteh: some helper union is also practical, while not well defined in C it usually works in some implementation defined way
01:29 AM tecdroid: well.. this is the native can_t from avr-can-lib.. i don't know it it's clever to wrap it
01:29 AM tecdroid: but i know what you mean
01:29 AM cehteh: you only wrap it for the conversion
01:32 AM cehteh: union int32_deserialize { int32_t as32; char as8[4];}; int32_t d32 (const char* src) { union int32_deserialize ret; ret.u8[3] = src[0]; ... ; return ret.as32; }
01:32 AM tecdroid: funny thing is, destination and acceleration are read correctly
01:32 AM cehteh: (or otther ways around)
01:33 AM cehteh: well maybe your bug is somewhere else
01:33 AM tecdroid: question is, how to find it.. i'll try to strip my code a little
01:33 AM cehteh: doesnt the canlib have some deserializer?
01:33 AM tecdroid: no
01:33 AM cehteh: strimp more, add debigging instrumentation, asserts ...
02:00 AM Maya-sama is now known as Miyu
02:42 AM Miyu is now known as hackkitten
03:35 AM tecdroid: gnaa.. think my problem is more the sprintf function than anything else..
05:02 AM tecdroid: somethings really strange with my compiler I think..
05:04 AM twnqx: possible you are using the wrong versioon of it while linking?
05:06 AM cehteh: nah .. its your code, some UD
05:08 AM twnqx: are those TO_xxx thingies macros?
05:08 AM twnqx: if so, can you post them?
05:09 AM twnqx: also, %0x... looks wrong to ,e
05:09 AM twnqx: you probably want %02x
05:09 AM tecdroid: XD
05:10 AM tecdroid: seems that avrclib sprintf doesn't like %x.. or %f.. at least mine doesn't
05:10 AM twnqx: %f needs a variant with flaot, yes
05:10 AM cehteh: dont use floats on avr's
05:10 AM twnqx: that's something to set in your makefile
05:11 AM cehteh: and printf is a bit limited on AVR unless you give some extra bloat options .
05:17 AM tecdroid: sometimes you need float.
05:17 AM cehteh: when?
05:18 AM cehteh: AVR's are the wrong chips then anyway
05:25 AM tecdroid: don't think so
05:25 AM tecdroid: those calculations aren't fast but as long as you put them somewhere uncritical, it's okay
05:41 AM twnqx: i have a similar issue atm
05:41 AM twnqx: and wondering if i should go float or fixed point integer
05:41 AM twnqx: i need fractional increments for acceleration of a stepper motor
05:47 AM tecdroid: thats what i am currently dieing with XD
05:49 AM day: be lazy use float
05:58 AM tecdroid: well.. i don't need it that precise so i use integers only.. only important thing is that steps are correct :)
05:58 AM twnqx: i am tracking milliseconds between steps
05:59 AM twnqx: i don't care if it's exact, but i found that at times i need 1.5 increment, or i won't reach "full speed" :P
06:02 AM tecdroid: well.. i need a maximum acceleration
06:02 AM tecdroid: which is important ;)
06:02 AM day: #define MAXPOWER 0xFF
06:02 AM * day plays eurobeat
06:02 AM tecdroid: XD
06:18 AM tecdroid: should have done a rewrite my program.. used a project i started about 4 years ago..
06:50 AM cehteh: twnqx: integer for sure floats is waaaay to slow
06:50 AM cehteh: been there .. written my stepper driver, its still not perfect even in integer
06:51 AM cehteh: https://public.pipapo.org/20190411_112616.mp4
07:10 AM twnqx: fixed int you mean?
07:12 AM cehteh: yes
07:16 AM day: you know it is called double, because it doubles the speed!
07:18 AM LeoNerd: It's called a double because it has more fat than a single but not quite as much as a whipping
07:32 AM Fuchikoma: https://sites.google.com/site/avrasmintro/home/integer-ratios-for-faster-code
07:32 AM Fuchikoma: Math not fast enough? Get creative! :D
08:34 AM Snoras_ is now known as Snoras
10:27 AM polprog: Fuchikoma: we learnt about the taylor series recently, i kinda want to fork some quake engine code and implement some bad approximations to see what's gonna break and how
10:27 AM polprog: "Quake 2, but sin x = x"
10:32 AM polprog: these tricks are awesome
10:41 AM Fuchikoma: sin(x) = x for very small values of x - actually a good thing to know depending on what you're doing
12:52 PM Snoras_ is now known as Snoras
11:08 PM rue_shop2: maybe thats why all the sine waves out of the stm32 math library come out all wierd
11:32 PM day__ is now known as day