#robotics Logs

Jan 14 2022

#robotics Calendar

02:33 AM Jak_o_Shadows: It'd be interesting to solve it, and step through and see the force multiplication you get, etc .
10:47 AM Urawa- is now known as Urawa
01:48 PM Tom_itx is now known as Tom_L
08:24 PM kerfluffy: anyone know why robot snakes all use servos and not steppers?
08:24 PM rue_mohr: power/weight ratio
08:24 PM rue_mohr: sucks for steppers
08:24 PM kerfluffy: right
08:25 PM kerfluffy: what makes servos have a better ratio?
08:25 PM rue_mohr: dc motor
08:25 PM kerfluffy: righ
08:25 PM rue_mohr: the magnetics aren't as big/heavy
08:25 PM kerfluffy: right
08:26 PM Tom_L: lighter motor with more gearing
08:27 PM rue_mohr: if you see quad copters with steppers, then they bridged the gap
08:29 PM kerfluffy: thanks
08:46 PM rue_mohr: hmm this state machine system has a few too many numbering systems...
10:16 PM Jak_o_Shadows: Custom C state machine?
10:16 PM Jak_o_Shadows: I was using the QT C++ state machine the other day
10:21 PM rue_mohr: no
10:21 PM rue_mohr: binary one
10:21 PM rue_mohr: uint8_t FSMLUT[] = {
10:21 PM rue_mohr: 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x05,0x06,0x08,0x09,0x00,0x00,0x00,
10:21 PM rue_mohr: 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
10:21 PM rue_mohr: 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x05,0x06,0x10,0x10,0x23,0x23,0x23,
10:21 PM rue_mohr: 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
10:21 PM rue_mohr: 0x20,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x05,0x06,0x07,0x09,0x04,0x04,0x04,
10:21 PM rue_mohr: 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
10:21 PM rue_mohr: 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
10:21 PM rue_mohr: 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30
10:21 PM rue_mohr: }
10:21 PM rue_mohr: IP = (E & 0x1F) | (state << 5);
10:21 PM rue_mohr: state = FSMLUT[IP] >> 4:
10:21 PM rue_mohr: EO = FSMLUT[IP] & 0x0F;
10:21 PM rue_mohr: ^^^ thats the only execution code
10:22 PM Jak_o_Shadows: Where does the work actually get done? The QT one has (optional) callback functions on state change
10:22 PM rue_mohr: IP = input, state is state, EO is the event output
10:22 PM rue_mohr: those two lines of coe
10:22 PM rue_mohr: de
10:22 PM rue_mohr: code
10:23 PM rue_mohr: IP = conditions the inputs to it
10:23 PM rue_mohr: the other two lines split out the next state vs the resulting event from the lookup
10:23 PM rue_mohr: want to see the switch mountian it executes?
10:24 PM Jak_o_Shadows: Is the switch mountain where the actual work gets done? Like what you do when changing state?
10:24 PM rue_mohr: no
10:25 PM rue_mohr: those 3 lines of code are it
10:25 PM rue_mohr: they do a whole pass of the state machine
10:25 PM rue_mohr: that binary blob, is this
10:25 PM rue_mohr: http://paste.debian.net/1227172/
10:25 PM rue_mohr: but run thru my compiler
10:25 PM rue_mohr: so those 3 lines are all you need to do
10:26 PM rue_mohr: your lost beyond belief aren't ya?
10:26 PM rue_mohr: :( I bet woz could run circles around me
10:27 PM rue_mohr: its not a compressed state machine tho, its just bitmasked
10:27 PM rue_mohr: to use a compressed one, you need to be able to do a multiply, and I'm on an arduino, so I dont want to do that
10:28 PM rue_mohr: unfortunatly, my application requires a lot of mapping values in and out of the machine
10:30 PM Jak_o_Shadows: If you want to set a LED to turn on when changing from state x to state y
10:30 PM Jak_o_Shadows: where does that get done?
10:30 PM rue_mohr: X and Y being input states?
10:31 PM Jak_o_Shadows: x being the initial, y being the state you change to
10:31 PM rue_mohr: ok
10:32 PM rue_mohr: there is a symmantic ommision, my state machines take in events and output events, so, the code to act on the output events is seperate
10:32 PM rue_mohr: let me try to think here
10:32 PM rue_mohr: lets take 4 input events
10:32 PM rue_mohr: A, B, C, D
10:32 PM rue_mohr: what sequence of events do you want to turn on the led?
10:33 PM rue_mohr: I can cheat with your query
10:33 PM Jak_o_Shadows: starting to think we think about state machines differently
10:33 PM Jak_o_Shadows: but anyway, any given event
10:33 PM Jak_o_Shadows: Like, event A
10:34 PM rue_mohr: ok, lets say that led is turned on when the state machine gets the Events BBC
10:34 PM rue_mohr: there will be a few states in there
10:35 PM rue_mohr: I will have the machine start at S1
10:35 PM rue_mohr: the event B will send it to S2
10:35 PM rue_mohr: any other event will keep it at S1
10:36 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/p1220628.jpg
10:36 PM rue_mohr: oh good! its not me naked
10:37 PM rue_mohr: you good with that so far?
10:38 PM rue_mohr: to get to S2, another B event needs to happen, lets have any other event send you back to S1
10:39 PM rue_mohr: hey?
10:39 PM rue_mohr: kinda following?
10:39 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/p1220629.jpg
10:39 PM rue_mohr: thats for the second B event
10:39 PM rue_mohr: Jak_o_Shadows, stay with me!....
10:40 PM rue_mohr: for all these state changes so far, the machine changes state, but does not emit an event
10:40 PM rue_mohr: think of this as a 4 key combination lock
10:42 PM * rue_mohr Jak_o_Shadows hey come back!
10:43 PM rue_mohr: :( back to my corner
10:44 PM rue_mohr: you can talk to me if you want Rue...
10:45 PM rue_mohr: its not quite the same, I know you already know eveything
10:45 PM rue_mohr: yea, but talking it out might make you realize something more
10:45 PM rue_mohr: I think at this point I just need more practise
10:45 PM rue_mohr: so, do things
10:46 PM rue_mohr: its not that easy, I dont find applications every day that I can even apply a state machine to
10:46 PM rue_mohr: well, true, there is a minimum complexity
10:47 PM rue_mohr: I need you to teach me how to implement AIs in state machines
10:47 PM rue_mohr: you need to do more parallel computing stuff ;)
10:47 PM rue_mohr: state machines on parallel processors?
10:47 PM rue_mohr: uhu
10:47 PM rue_mohr: but... how....
10:48 PM rue_mohr: see thats your room to grow, right there bud.
10:48 PM rue_mohr: heh, maybe use up the Z80s :)
10:48 PM rue_mohr: make sure you can recycle what you learn on commodity hardware
10:48 PM rue_mohr: how can I transfer myself to hardware tho
10:49 PM rue_mohr: make the hardware and then worry about that, answers aren't secret
10:49 PM rue_mohr: its software right? like why we didn't have 3d printers in 1980
10:49 PM rue_mohr: :)
10:50 PM rue_mohr: I got 2200 twitter followers, when will I get to the people I need to reach?
10:50 PM rue_mohr: its like lightning, there are odds you could just miss them all
10:50 PM rue_mohr: all what, like 5 in THE WORLD?
10:51 PM rue_mohr: :)
10:51 PM rue_mohr: I can't even be sure where I am, like advancement wise
10:51 PM rue_mohr: look around, who understands your state machines?
10:52 PM rue_mohr: well no the 35 here, and not the 2200 on twitter
10:52 PM rue_mohr: exactly
10:52 PM rue_mohr: so, your saying i'm doing good?
10:52 PM rue_mohr: your doing fine, its still a tight race, so dont doddle
10:53 PM rue_mohr: its really hard to run a race when you cant see the other contestants
10:54 PM rue_mohr: and I got nobody to bounce ideas off, I just sound like a crazy loon to everyone. It really doesn't help
10:54 PM rue_mohr: how do you think peers would help?
10:54 PM Jak_o_Shadows: sorry, just getting lunch
10:54 PM Jak_o_Shadows: back in a few minutes
10:55 PM rue_mohr: two minds have to come up with more random variations than one
10:56 PM rue_mohr: so you think the key forward is random variations?
10:56 PM rue_mohr: well, and logical idea evolution
10:56 PM rue_mohr: you want an upside down thinker
10:56 PM rue_mohr: I'm not sure if I'm the upside down one bud
10:56 PM rue_mohr: heh
10:57 PM rue_mohr: I need a group with the rightside up and the inside out guy
10:57 PM rue_mohr: mhm, I wonder if we can find them for you
10:57 PM Jak_o_Shadows: Yeah, was following
10:57 PM rue_mohr: I'm waiting, but I'm giving up
10:57 PM rue_mohr: Jak_o_Shadows, are you back?
10:57 PM Jak_o_Shadows: yep
10:57 PM Jak_o_Shadows: soz
10:57 PM rue_mohr: I dont even know where I was
10:58 PM Jak_o_Shadows: http://ruemohr.org/~ircjunk/tempimage/p1220629.jpg
10:58 PM rue_mohr: you were building up the state machine
10:58 PM rue_mohr: k
10:58 PM Jak_o_Shadows: I also agree about state machines on parallel processes, that could be interesting
10:58 PM rue_mohr: ok, so..
10:58 PM rue_mohr: we need an event C to take it to uh, S4
10:59 PM rue_mohr: so, at S4, our right is on
10:59 PM Jak_o_Shadows: So events are things that happen to you? You dont do any work in them?
10:59 PM rue_mohr: right
10:59 PM rue_mohr: key presses
10:59 PM Jak_o_Shadows: Got it
10:59 PM rue_mohr: they trigger you to move (maybe) to a new state
11:00 PM Jak_o_Shadows: yuop
11:00 PM rue_mohr: so, whats not happening in this FSM is event emission
11:00 PM rue_mohr: but we dont need it, I'm gonna cheat
11:00 PM rue_mohr: S1 will have a binary value of 0
11:01 PM rue_mohr: but S4 will have a value of 4
11:01 PM rue_mohr: which means the led connects to bit 4 of the state number
11:01 PM rue_mohr: I'll show in more detail
11:01 PM rue_mohr: from S3 lets make any wrong event send you back to S1
11:01 PM Jak_o_Shadows: So states are encoded as numbers
11:01 PM Jak_o_Shadows: that's all cool
11:01 PM rue_mohr: yes
11:02 PM Jak_o_Shadows: Then something in parallel reacts to that?
11:02 PM rue_mohr: let me bang this out for ya
11:02 PM rue_mohr: I'll do the code and you can built it
11:02 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/p1220630.jpg
11:03 PM rue_mohr: so, from S4, does any state take us back to S1, or another sequence?
11:03 PM Jak_o_Shadows: Any state
11:03 PM Jak_o_Shadows: keep it simple
11:03 PM rue_mohr: k
11:03 PM rue_mohr: now, we number the events and the states
11:04 PM rue_mohr: enum states_e { S1 = 0, S2, S3, S4 = 4 };
11:05 PM rue_mohr: enum events_e { EA = 0, EB, EC, ED };
11:05 PM rue_mohr: all good?
11:05 PM Jak_o_Shadows: yup
11:05 PM rue_mohr: so, this state machine has a 2 bit input,
11:06 PM rue_mohr: and 3 bits of state feedback, bit 2 is hooked up to an LED
11:06 PM rue_mohr: so, the state machine being on S4 will cause the led to be ok
11:06 PM rue_mohr: on
11:06 PM Jak_o_Shadows: How do you hook it up to the LED
11:09 PM rue_mohr: a hardware implementation of the machine...
11:09 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/p1220631.jpg
11:09 PM Jak_o_Shadows: ohhhhh
11:09 PM rue_mohr: tell me if that makes sense
11:09 PM Jak_o_Shadows: Yep
11:09 PM rue_mohr: now, this can be done in code as all software too
11:09 PM Jak_o_Shadows: yeah
11:09 PM rue_mohr: if it were in software you would check for bit 4 and do things
11:10 PM rue_mohr: so
11:10 PM Jak_o_Shadows: Yeah, you'd have a switch statement for the state changes, and a switch statement for the on-enter state functions
11:10 PM rue_mohr: no
11:10 PM rue_mohr: you can do it with a LUT still
11:10 PM Jak_o_Shadows: ah, yeah, sorry.
11:10 PM rue_mohr: np
11:11 PM rue_mohr: we can make a switch block to compile the machine
11:11 PM Jak_o_Shadows: But the key piont is that it's separate
11:11 PM rue_mohr: but I want to compile this by hand
11:11 PM rue_mohr: to show ya
11:11 PM rue_mohr: we need a 32 byte rom
11:11 PM rue_mohr: (5 bits)
11:12 PM rue_mohr: 000 00 so, state is S1 (0) , and event is A (0)
11:12 PM Jak_o_Shadows: the 2 bit input, the 3 bit states
11:12 PM rue_mohr: ^^ binary for simplicity
11:12 PM rue_mohr: oh I'm left justified, sorry, I'll carry on and just dont let it give you a headache
11:13 PM Jak_o_Shadows: What's the advantage of doing it in hardware?
11:13 PM rue_mohr: oh, 000 00 is S1, A so, we want to keep the state as S1
11:13 PM rue_mohr: well, I'v done all sorts of crazy hardware things
11:13 PM rue_mohr: from sequencers to controllers
11:13 PM Tom_L: you did this in fpga didn't you?
11:14 PM rue_mohr: I love to use this for encoders
11:14 PM rue_mohr: I did
11:14 PM Jak_o_Shadows: ahhhh
11:14 PM Jak_o_Shadows: Oh, that makes absolute sense
11:14 PM rue_mohr: it turns out, I did a romless stepper sequencer based on the same process
11:15 PM rue_mohr: cause the rom was 2 XOR gates
11:15 PM rue_mohr: which is the only time yet something reduced like that on me
11:15 PM rue_mohr: ok, so we need to build this table
11:16 PM rue_mohr: 000 00 is S1 A so the data out for that is 000 (stay at S1)
11:16 PM rue_mohr: 100 00 is S1 B so the data for that is 100 (goto S2)
11:17 PM rue_mohr: is this making sense?
11:17 PM rue_mohr: oh no I messed that up
11:17 PM rue_mohr: 100 00 is S2 A so the data for that is 000 (goto S1)
11:17 PM Jak_o_Shadows: Can't make a compiler to do this for you?
11:18 PM rue_mohr: yes, I have one
11:18 PM rue_mohr: I'm trying to do an example by hand
11:18 PM rue_mohr: shall I use the compiler and skip to the answer so we can implement?
11:18 PM Jak_o_Shadows: yesh
11:18 PM rue_mohr: k
11:19 PM rue_mohr: get a drink ;)
11:19 PM rue_mohr: something strong
11:20 PM Jak_o_Shadows: aha
11:20 PM rue_mohr: where are those enums..
11:21 PM rue_mohr: #define InputBits 5
11:21 PM rue_mohr: uint16_t EVI, STI; // Event in, state in
11:21 PM rue_mohr: uint8_t STO; // state out
11:21 PM rue_mohr: I'm just throwing peices while I code
11:22 PM Jak_o_Shadows: 👍
11:23 PM rue_mohr: spliceValueFromField( &EVI, A, 2, 0,1); // 2 bit event in
11:23 PM rue_mohr: spliceValueFromField( &STI, A, 3, 2,3,4); // 3 bit state out
11:25 PM rue_mohr: switch(STI) {
11:25 PM rue_mohr: case S1:
11:25 PM rue_mohr: switch(EVI) {
11:25 PM rue_mohr: case EA : STO = ; break;
11:25 PM rue_mohr: case EB : STO = break;
11:25 PM rue_mohr: case EC : STO = break;
11:25 PM rue_mohr: case ED : STO = break;
11:27 PM rue_mohr: switch(STI) {
11:27 PM rue_mohr: case S1:
11:27 PM rue_mohr: switch(EVI) {
11:27 PM rue_mohr: case EB : STO = S2; break;
11:27 PM rue_mohr: }
11:27 PM rue_mohr: break;
11:27 PM rue_mohr:
11:27 PM rue_mohr: case S2:
11:27 PM rue_mohr: switch(EVI) {
11:27 PM rue_mohr: case EB : STO = S3; break;
11:27 PM rue_mohr: }
11:27 PM rue_mohr: break;
11:27 PM rue_mohr:
11:27 PM rue_mohr: case S3:
11:27 PM rue_mohr: switch(EVI) {
11:27 PM rue_mohr: case EC : STO = S4; break;
11:27 PM rue_mohr: }
11:28 PM rue_mohr: break;
11:28 PM rue_mohr:
11:28 PM rue_mohr:
11:28 PM rue_mohr: }
11:28 PM rue_mohr: that could be an If block, ugh
11:28 PM rue_mohr: too simple
11:29 PM rue_mohr: 0000: 00 01 00 00 00 02 00 00 - 00 00 04 00 00 00 00 00 ................
11:29 PM rue_mohr: 0010: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
11:29 PM rue_mohr: yea, waaaaaay too simple
11:29 PM rue_mohr: so, lets make it a C array
11:29 PM rue_mohr: which I should make an option in my compiler
11:30 PM rue_mohr: FSMLUT[] = {
11:30 PM rue_mohr: 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
11:30 PM rue_mohr: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
11:30 PM rue_mohr: };
11:30 PM rue_mohr: ok, now lets use it
11:31 PM rue_mohr: so, to make the index, we bitwise construct it from the event number and the current state
11:32 PM rue_mohr: i = state | (event << 3);
11:32 PM rue_mohr: so bits 0-2 are the state
11:33 PM rue_mohr: and bits 3,4 are the event number
11:33 PM rue_mohr: the result is 3 bits, and bit 2 is the LED
11:33 PM rue_mohr: state = FSM[i];
11:34 PM rue_mohr: and led = state & 0x04;
11:34 PM rue_mohr: for the software thing
11:34 PM Jak_o_Shadows: I'm going to be using vitis HLS to translate C to FPGA
11:34 PM Jak_o_Shadows: I wonder how nicely this will go
11:34 PM rue_mohr: you dont have to do it from C
11:34 PM Jak_o_Shadows: C++
11:35 PM rue_mohr: so, make a lut with that data in it
11:35 PM rue_mohr: build the address from those two things, have a D latch between the LUT output and the state inputs
11:35 PM Jak_o_Shadows: On a FPGA, where would I put the LUT?
11:35 PM rue_mohr: only clock it when your sending it a new event
11:36 PM Jak_o_Shadows: Or would it be encoded into your fabric
11:36 PM rue_mohr: I only know verilog
11:36 PM Jak_o_Shadows: I haven't picked up any verilog of vhdl yet
11:36 PM Jak_o_Shadows: or*
11:36 PM rue_mohr: if you want I can do that direction, shall I do C or verilog?
11:37 PM rue_mohr: cant test the verilog just now tho,
11:37 PM rue_mohr: want to do PC code and use printf?
11:37 PM Jak_o_Shadows: Does the LUT get encoded into the fabric, or is it still a LUT to be looked up via RAM
11:37 PM Jak_o_Shadows: Because waiting for RAM access may actually increase the latency
11:37 PM rue_mohr: oh, I usually encode it
11:38 PM rue_mohr: verilog kinda has a switch statement you can use
11:38 PM Jak_o_Shadows: ah
11:39 PM Jak_o_Shadows: I'm going to try using Vitis, which compiles your C++ down to VHDL/Verilog
11:39 PM rue_mohr: ok
11:39 PM Jak_o_Shadows: (via a LLVM IR)
11:39 PM rue_mohr: like you said, I'm not sure how to connect it then
11:39 PM rue_mohr: I can do a thing using printf'
11:40 PM Jak_o_Shadows: I think C switches probably will be compiled better
11:40 PM Jak_o_Shadows: as a guess
11:40 PM rue_mohr: yes
11:40 PM rue_mohr: its a bit odd, casue to get the binary in, you use a switch
11:40 PM rue_mohr: I'm not aware of how to do a lookup otherwise in verilog
11:41 PM rue_mohr: but it turns into a LUT on the fpga
11:41 PM Jak_o_Shadows: Yeah
11:41 PM rue_mohr: I'll do a C thing for command line...
11:41 PM Jak_o_Shadows: The thing with the C -> VHDL compliation - it can get really hard to follow
11:42 PM Jak_o_Shadows: It does optimisations and whatnot
11:43 PM rue_mohr: yes
11:44 PM rue_mohr: its a bit of a silly circle to make C to implement a hardware state machine and have a system turn it back into hardware
11:44 PM rue_mohr: my cat must not like me listing to music on my headphones, he's trying to help me type
11:45 PM rue_mohr: http://paste.debian.net/1227173/
11:45 PM rue_mohr: see roughly were I'm going?
11:45 PM Jak_o_Shadows: I think so
11:45 PM rue_mohr: you on linux or windows?
11:46 PM Jak_o_Shadows: windows, through i can do linux - just need to remote in
11:48 PM rue_mohr: what the hell does the cat want!!!
11:48 PM rue_mohr: brb
11:49 PM rue_mohr: wants nothing, but wants it badly
11:49 PM Jak_o_Shadows: typical cat
11:51 PM rue_mohr: oh thats what I get for changing the name of that dumb pointer
11:51 PM * rue_mohr smashes it with a hammer
11:56 PM rue_mohr: it looks like I messed something up, funny seeing as this is such a simple example
11:56 PM rue_mohr: spliceValueFromField( &EVI, A, 2, 0,1); // 2 bit event in
11:56 PM rue_mohr: spliceValueFromField( &STI, A, 3, 2,3,4); // 3 bit state out
11:57 PM rue_mohr: oh I masked it wrong
11:57 PM rue_mohr: i = state | (((*dumbptr) - 'A')<<3); is wrong
11:57 PM rue_mohr: i = ((*dumbptr) - 'A') | (state << 2);
11:58 PM rue_mohr: ok working code
11:58 PM rue_mohr: ok I think its commented and things well
11:58 PM rue_mohr: take a look at this and tell me if you can follow it
11:58 PM rue_mohr: http://paste.debian.net/1227175/
11:58 PM rue_mohr: gcc main.c
11:58 PM rue_mohr: a.out
11:58 PM rue_mohr: ./a.out
11:59 PM Jak_o_Shadows: Yup
11:59 PM rue_mohr: so
11:59 PM Jak_o_Shadows: It's the i = ... that does a lot of the work
11:59 PM rue_mohr: anything not make sense?