#robotics Logs

May 31 2017

#robotics Calendar

12:29 AM rue_house: ok, the challange is 50Hz interrupt
12:34 AM mrdata: what
12:34 AM mrdata: what sort of challenge is that
12:34 AM rue_house: a not easy one
12:34 AM mrdata: why
12:34 AM rue_house: for an stm32
12:34 AM orlock: its not easy
12:34 AM orlock: it sounds really painfull
12:34 AM orlock: so painfull it.. Hertz..
12:34 AM * orlock ducks
12:34 AM mrdata: you have an interrupt service routine doing what?
12:35 AM mrdata: rue_house, have you managed multiple threads in stm32?
12:36 AM mrdata: have you written ISRs at all?
12:37 AM orlock: mrdata: i thing he has not, and wants to see if hecan
12:38 AM orlock: which is why its a challange
12:38 AM orlock: multi-theads and ISR's on STM32, that is.
12:38 AM mrdata: mhm
12:39 AM * orlock has been down on the factory floor debugging robot build machines, fun
12:39 AM mrdata: now i'm not sure if this applies to stm32, but usually ISRs can only call routines that return quickly
12:39 AM orlock: i had to put on an ESD safe dust jacket and everything
12:40 AM rue_house: mrdata, mmm how about sending the letter 'U'
12:40 AM mrdata: eh?
12:40 AM rue_house: not for stm32
12:41 AM rue_house: I'd toggle an io pin, but I want to see results from my desk here
12:42 AM rue_house: [in another room]
12:44 AM rue_house: mrdata, so, you do stm32 programming much?
12:44 AM mrdata: not much
12:44 AM rue_house: ah
12:44 AM rue_house: then you dont know how to help me set up the timer 1 clocks?
12:44 AM mrdata: my ISR experience comes from x86 and 6502
12:44 AM rue_house: thats not helpfull
12:44 AM rue_house: I have a chain of clock control systems I need to figure out hwo to set up
12:44 AM mrdata: i did peruse the stm32 manual around those places but i didnt do the coding
12:44 AM rue_house: you should, I can help you get an led to flash
12:45 AM rue_house: Jak_o_Shadows, knows lots, but the git is in the wrong timezone
12:47 AM _Sol_ is now known as Solgriffin
12:55 AM rue_house: ok, if I use a 24Mhz clock supply, then set the prescaler to 10, and have the counter overflow at 48000, I will get my 50Hz
12:56 AM rue_house: rcc_clock_setup_pll(&rcc_clock_config[RCC_CLOCK_VRANGE1_HSI_PLL_24MHZ]);
12:56 AM rue_house: rcc_periph_clock_enable(RCC_TIM6);
12:56 AM rue_house: I think those are important
12:57 AM rue_house: timer_set_prescaler(TIM6, 10);
12:57 AM rue_house: timer_set_period(TIM6, 48000);
12:58 AM rue_house: then just ...
12:58 AM rue_house: nvic_enable_irq(NVIC_TIM6_IRQ);
12:58 AM rue_house: timer_enable_update_event(TIM6); /* default at reset! */
12:58 AM rue_house: timer_enable_irq(TIM6, TIM_DIER_UIE);
12:58 AM rue_house: timer_enable_counter(TIM6);
12:58 AM rue_house: and write void tim6_isr(void) { }
12:59 AM rue_house: apparently remembering to clear the interrupt flag in the ist
12:59 AM rue_house: r
12:59 AM rue_house: *blink*
01:07 AM rue_house: ok, so, going backwards
01:09 AM rue_house: timer2 gets is clock from its prescaler, that gets it from a prescaler that gets if from the APB1 prescaler that gets it from the AHB prescaler, that gets it from the clock source selector, of which I will use the HSE osc... which is running at 8Mhz
01:09 AM rue_house: er... no?
01:09 AM rue_house: the HSE will be the source for the PLL...
01:09 AM mrdata: um,
01:10 AM rue_house: head gonna explode
01:10 AM mrdata: use a slow blow fuse on the head
01:10 AM rue_house: oh, the fn already sets up the pll for 72Mhz
01:10 AM rue_house: rcc_clock_setup_in_hse_8mhz_out_72mhz();
01:11 AM mrdata: isnt a prescaler giving you a power of 2?
01:11 AM rue_house: its the modern age, some of them are a full 16 bit whatever-you-want prescaler
01:12 AM mrdata: so, 1/2, 1/4, 1/8, etc
01:13 AM mrdata: i havent been that deep into the stm32 manual in some time
01:13 AM rue_house: and this manual was hard to find
01:14 AM mrdata: but i assumed power of 2 because prescale is a very simple operation
01:14 AM mrdata: it's easy to divide a clock in halves
01:14 AM rue_house: good, cause I need to divide the 72Mhz by 3
01:15 AM mrdata: erk
01:15 AM rue_house: YOU SAID THIS WOULD BE SIMPLE
01:15 AM mrdata: no
01:15 AM mrdata: i said what sort of challenge is that
01:17 AM mrdata: but if 72 were to be divided by 8, then you'd have 9 MHz
01:17 AM rue_house: the clock bus for the timers can be max 36Mhz
01:18 AM mrdata: and 9 MHz / 180,000 is 50 Hz
01:18 AM rue_house: a) thats not helpfull for divisors that peak at 65536
01:18 AM mrdata: do they? hmm
01:18 AM rue_house: b) wtf, where the hell supposed to get 9Mhz!?
01:19 AM anonnumberanon: so i take it you haven't decided if an stm32 could drivve 17 servos without any other hardware?
01:19 AM mrdata: and i thought stm32 would hav 32 bit registers
01:19 AM rue_house: oh i think it could
01:19 AM mrdata: did the designation 32 lead me astray?
01:19 AM rue_house: I'm digging in
01:20 AM rue_house: it dosn't matter, the timers are 16 bits
01:20 AM mrdata: \lork
01:21 AM rue_house: http://libopencm3.org/docs/latest/stm32f4/html/group__timer__file.html
01:21 AM rue_house: oh...
01:23 AM mrdata: hmm... "The timer clock is prescaled by the 16 bit scale value plus 1."
01:24 AM mrdata: interesting
01:24 AM mrdata: ok
01:24 AM mrdata: you started at 72 MHz? then you need to get down to at most 3.27680 MHz
01:25 AM mrdata: so if scale+1 = 24 then you get 3 MHz
01:26 AM mrdata: which makes the count 60,000
01:28 AM rue_house: I dont know what the APB1 prescaler is set to
01:28 AM rue_house: I think AHB is 1
01:30 AM mrdata: but timer_set_prescaler() will set it?
01:31 AM rue_house: no
01:31 AM mrdata: then i'm not understanding the interface
01:31 AM rue_house: the clock goes from the pll to AHB prescaler, then thru APB1 prescaler, then the timer prescaler
01:32 AM mrdata: oh
01:32 AM rue_house: but if APB1 prescaler is 1, it gets multiplied by 2 before going to the timer prescaler
01:32 AM mrdata: i suppose there might be a way to test that
01:33 AM mrdata: so, you'd get some fraction of 50Hz as a result if it is scaling at all
01:34 AM rue_house: the RCC functions dont seem to have anything to do with the AHB prescaler
01:35 AM rue_house: which confuses me, cause that sets the main cpu clock
01:35 AM mrdata: but if so, then change the count to 30,000
01:35 AM rue_house: the AHB goes from 1 to 512
01:37 AM rue_house: oh
01:37 AM rue_house: I think, its been set to 36Mhz
01:38 AM rue_house: so lets go from 36Mhz to 50Hz
01:39 AM rue_house: 965 rcc_ahb_frequency = 72000000;
01:39 AM rue_house: 966 rcc_apb1_frequency = 36000000;
01:39 AM rue_house: 967 rcc_apb2_frequency = 72000000;
01:39 AM rue_house: oh look what they made for me
01:39 AM rue_house: ok, so 36Mhz
01:42 AM mrdata: ok
01:43 AM mrdata: so prescale would be set to 23, for 36 MHz/24 = 1.5 MHz, then count to 30,000
01:43 AM rue_house: well thats better than the prime number I'm trying to divide
01:44 AM mrdata: :)
01:51 AM mrdata: ok, i must sleep; nn
01:51 AM rue_house: yea
01:51 AM rue_house: me too
01:51 AM rue_house: looks like it'll be about 3 days for me to get this written
01:51 AM rue_house: :S
03:58 AM veverak: 17 servos?
03:58 AM veverak: sounds good
03:58 AM deshipu: black magic probe just arrived
04:31 AM To_Aru_Shiroi_Ne is now known as ToAruShiroiNeko
09:11 AM rue_house: 10*4
09:11 AM rue_house: 40 servos
09:23 AM veverak: rue_house: now you got my attention
09:26 AM rue_house: well I'm still working on getting a 50Hz interrupt, so, whatever
06:32 PM anniepoo: rue, your makefile keeps getting kicked down the road, I'm swamped this week
06:32 PM anniepoo: and got invited camping tomorrow and friday
07:15 PM Tom_L: i thought he got it working
07:51 PM rue_shop3: he did
07:51 PM Tom_L: he was rather happy about it too
07:52 PM rue_shop3: it took him a lot of work
07:52 PM Tom_L: what tool chain are you using?
07:52 PM Tom_L: i can't even recall what they suggested for the STM32F4 way back when...
07:52 PM Tom_L: there were a couple iirc
07:52 PM rue_shop3: there is gcc
07:52 PM rue_shop3: and make
07:53 PM Tom_L: what lib were you getting?
07:53 PM Tom_L: for what...
07:53 PM Tom_L: initialization?
07:53 PM Tom_L: seems there are more setup steps for an arm than there even was for the 68332 i played with
07:55 PM zhanx: non eabi arm gcc, but depends on the system etc i think
07:55 PM Tom_L: eabi?
07:57 PM zhanx: gcc-arm-none-eabi is the package on my system
07:58 PM Tom_L: hmm
07:58 PM zhanx: embedded floating point
07:58 PM Tom_L: you messin with arm too then?
07:58 PM zhanx: i got a couple of the cheap china ones yes i play with when i get a chance
07:59 PM Tom_L: i got a discovery board here i've never opened
07:59 PM zhanx: think i got one also like that
07:59 PM zhanx: the f4
07:59 PM Tom_L: yep
07:59 PM zhanx: the freebie deal also?
07:59 PM Tom_L: yep
08:00 PM zhanx: now that i am back to work, i got no time, between kids, garden and basics
08:04 PM rue_shop3: zhanx, thats it
08:05 PM rue_shop3: along with libopencm3
08:05 PM rue_shop3: which is a pain in the ass, you cant use the newest version and you have to mod one of the scripts
08:05 PM rue_shop3: to undo something someone tried to add to it
08:25 PM anonnumberanon is now known as danonnumberanon
08:38 PM danonnumberanon is now known as anonnumberanon
09:23 PM rue_house: veverak, but you have to use 4 4017, so your prolly not interested
09:24 PM rue_house: sure be nice to have someone working with me on the stm32 stuff
09:24 PM rue_house: someone to say take the serial demo I did, and set up the adc, to use the serial to report a value
10:09 PM Tom_L: rue_house, i don't think i could keep up anymore
10:09 PM Tom_L: time is a rare commodity
10:10 PM rue_house: I dont know if it would do much for you right now
10:10 PM rue_house: I'm doing it for future proofing
10:10 PM rue_house: I'll share what I come up with
10:10 PM z64555: proving that the future exists?
10:12 PM rue_house: pff
10:12 PM rue_house: futureproofing is to make sure it dosn't
10:12 PM rue_house: duh
10:12 PM z64555: ah yes, of course
10:15 PM rue_house: make: Warning: File `main.c' has modification time 25 s in the future
10:15 PM rue_house: I have figured out how to use make to check if the future really exists
10:15 PM rue_house: I know that the next 25 seconds WILL exist!
10:15 PM rue_house: and I'll still be adjusting my damn source code
10:18 PM Tom_L: but they didn't
10:18 PM rue_shop3: ok I have a timer blinking an led via polled main loop code
10:18 PM Tom_L: it was augmented reality
10:19 PM Tom_L: are arms that complicated to set the initialization on?
10:20 PM rue_house: there is a library, but not much of a road map
10:20 PM rue_house: you have to do things like enable the clock lines to all the perphial systems
10:21 PM rue_house: http://paste.debian.net/957141/
10:21 PM Tom_L: sorta like a fpga where you gotta connect all the signals
10:21 PM rue_house: well I wouldn't know that now would I?
10:21 PM Tom_L: you could
10:21 PM rue_house: no fpga hardware
10:21 PM rue_house: :/
10:22 PM Tom_L: i got a jtag for one here somewhere and can't find it
10:22 PM Tom_L: for xilinx
10:23 PM z64555: clock lines, peripheral systems? These are on the same chip, arn't they?
10:23 PM rue_house: its the software to run the jtag, the jtag programmer, the fpga interface, and the fpga support hardware
10:24 PM rue_house: z64555, http://paste.debian.net/957141/
10:24 PM Tom_L: it's all part of their ise environment
10:24 PM z64555: something like a demo board?
10:25 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/temp/xilinx1.jpg
10:25 PM Tom_L: that's an old one i have
10:25 PM z64555: yeah, demo/evaluation board
10:26 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/temp/xilinx/
10:26 PM Tom_L: some early test code i did
10:26 PM anniepoo: hey, after struggling with several types of bed cover, Kevin tried some transfer film, of the sort used for vinyl signs
10:26 PM anniepoo: this worked really well
10:26 PM anniepoo: rue, if you're on, I have a few cycles to look at your makefile now
10:27 PM anniepoo: I closed that window
10:27 PM anniepoo: 8cP crazy week for work
10:28 PM rue_house: http://ruemohr.org/~ircjunk/programming/c/stm32/blink2/Makefile
10:28 PM rue_house: the intent was to try to clean it up some
10:34 PM rue_house: heh, an overflow interrupt isn't that easy
10:35 PM Tom_L: why not?
10:35 PM rue_house: its not just an up counter
10:36 PM z64555: auto-reset?
10:36 PM rue_house: it counts up, or down, or updown, or sideways
10:36 PM Tom_L: hmm
10:36 PM z64555: oh
10:36 PM rue_house: all I'm trying to find now is a list of interrupts I can enable for the timer
10:36 PM Tom_L: so if adjustments are made it may never overflow
10:36 PM Tom_L: what chip is it?
10:37 PM z64555: what's a sideways counter?
10:37 PM rue_house: I think what I want isn't called overflow anymore
10:37 PM rue_house: z64555, I think its imaginary
10:37 PM rue_house: its an stm32F103C8T6 iirc
10:37 PM Tom_L: https://visualgdb.com/tutorials/arm/stm32/timers/
10:37 PM z64555: so it increments a different register?
10:38 PM rue_house: it looks like any timer can trigger any other timer
10:38 PM Tom_L: http://en.radzio.dxp.pl/stm32vldiscovery/lesson4,blinking,with,timer,interrupts.html
10:39 PM rue_house: ok
10:39 PM rue_house: oh
10:39 PM rue_house: damn I wish they would put diagrams in these
10:40 PM Tom_L: find a tutorial with diagrams :)
10:41 PM Tom_L: https://visualgdb.com/tutorials/arm/stm32/timers/hal/
10:41 PM Tom_L: same as first link but uses 'hal' whatever that is
10:41 PM rue_house: they keep calling it 'update interrupt'
10:41 PM rue_house: I dont know what that means
10:42 PM rue_house: Hardware Abstraction Layer
10:42 PM rue_house: aka, more code, runs slower, promises to be portable
10:42 PM Tom_L: so there's 2 methods
10:42 PM rue_house: usually empty promises
10:44 PM rue_house: cc1ie cc2ie cc3ie uie
10:44 PM Tom_L: seems raw code is the difficult way but libraries make it simpler but harder to understand what they do
10:44 PM rue_house: I'm chewing thru it
10:45 PM rue_house: there are 4 compare systems (cc)
10:45 PM Tom_L: i don't have enough hours left to jump on board this one
10:45 PM rue_house: and an update flag
10:47 PM Tom_L: http://www.st.com/content/ccc/resource/technical/document/application_note/group0/91/01/84/3f/7c/67/41/3f/DM00236305/files/DM00236305.pdf/jcr:content/translations/en.DM00236305.pdf
10:47 PM Tom_L: timer cookbook from ST
10:53 PM Tom_L: early day tomorrow... later
10:55 PM rue_house: I have enough info, I just need to process it
11:06 PM rue_house: whats giving me the most grief is the code examples that dosnt use the library
11:22 PM rue_shop3: YES!
11:28 PM rue_house: http://paste.debian.net/957241/
11:28 PM rue_house: interrupt controlled flashing
11:28 PM rue_house: so, 50Hz wont be much of a stretch
11:29 PM * rue_house thinks
11:30 PM rue_house: so, I wont go into making the timer trigger a dma that basically acts as a shift register to an io port
11:30 PM rue_house: but I'll set up a second timer to trigger with the first timer to do the high resolution pwm pulses
11:31 PM rue_house: for 2.5ms
11:31 PM rue_house: with a 16 bit counter
11:31 PM rue_house: 2.5ms aka 2500us
11:32 PM rue_house: so a count rate of .0381us
11:32 PM rue_house: 26214381hz
11:32 PM rue_house: 26214.381 khz
11:32 PM rue_house: 26.214381 Mhz
11:33 PM rue_house: the primary clock source is 72Mhz
11:33 PM rue_house: divider of 2.7
11:33 PM rue_house: k
11:33 PM rue_house: if I underdivide and cut the top off
11:34 PM rue_house: 36Mhz
11:35 PM rue_house: 3...
11:35 PM rue_house: yea
11:36 PM rue_house: ok, I divide the 72Mhz by 3 to get 36Mhz, and then I cap the count to 60000
11:36 PM rue_house: which gives me 2.5ms
11:36 PM rue_house: and I can slave the counter somehow
11:37 PM rue_house: so I dont need any software to repeat the servo pulse
11:37 PM rue_house: s
11:37 PM rue_house: 50hz is...
11:37 PM rue_house: 20ms
11:38 PM rue_house: 20ms / 2.5ms is 8 channels
11:38 PM rue_house: so, if you want good range on the servos, you can only do 8 channels per timer
11:38 PM rue_house: which means a total of 32 servos for each timer
11:38 PM rue_house: the f103 has 3 timers, so your limited to 64 servos
11:39 PM rue_house: using 8 4017
11:39 PM rue_house: each servo having a resolution of 60000 counts....
11:40 PM rue_house: but ofcourse nobody cares about resolution or clock stability with servos
11:40 PM rue_house: now, problem
11:40 PM rue_house: my protocol only handles 32 servos per serial bus
11:40 PM rue_house: *but* the f103 has 3 uarts
11:44 PM rue_house: ok, stepping back
11:44 PM rue_house: no, I'm still ignoring the fact that 64 servos can pull 64A
11:44 PM rue_house: but I'm thinking on the origional goal
11:44 PM rue_house: which was the force feedback
11:44 PM rue_house: using the stm32, not because its better or soemthing, b
11:45 PM rue_house: but becasue it gives me a goal for getting into stm32 stuff
11:45 PM rue_house: so, what I need to do is control 1 servo
11:45 PM rue_house: and thats good, I'm close
11:45 PM rue_house: but then I need to do pulse capture
11:46 PM rue_house: for 50ms
11:46 PM rue_house: no, 50hz
11:46 PM rue_house: right, for 50hz
11:46 PM rue_house: which is 2.5ms
11:46 PM rue_house: no its not
11:46 PM rue_house: yea, cause its 20ms
11:46 PM rue_house: yea
11:47 PM rue_house: so, what is the lowest divider I can use to get 20ms
11:47 PM rue_house: 50hz
11:47 PM rue_house: were starting with 24Mhz
11:47 PM rue_house: no were not
11:47 PM rue_house: its 36Mhz
11:47 PM rue_house: ...ok
11:57 PM mrdata_ is now known as mrdata