Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Corrections. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: | c34bc3685455b5aca52160338878ec1be146c229a11ca4e41b6e828ee78a40b8 |
User & Date: | gwlester 2018-01-30 02:55:22 |
Context
2018-01-30
| ||
23:33 | Working Gryoscope example. check-in: fcc1329691 user: gwlester tags: trunk | |
02:55 | Corrections. check-in: c34bc36854 user: gwlester tags: trunk | |
2018-01-29
| ||
06:15 | changes for dIMU initial implementation of gryoscope. check-in: bfc9ec1028 user: gwlester tags: trunk | |
Changes
Changes to Gryo_Example.tcl.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 ... 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 ... 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 ... 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ... 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
array set GyroValues { 250dps 0x00 500dps 0x10 2000dps 0x30 250dps,divisor 128.0 500dps,divisor 64.0 2000dps,divisor 16.0 divisor 1.0 full_scale_range 0x30 gryo,x,axis 0x14 gryo,y,axis 0x16 gryo,z,axis 0x18 rate 50 freq 10 } set i2cbus 1 set dIMUaddress 0x28 set range 2000dps proc StartGyro {handle range} { global GyroValues ## ## Place the dIMU in configuration mode ## bno055 writeRegister $handle operMode [bno055 getValue OPER_MODE_CONFIGMODE] ................................................................................ ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisGeading {axis} { global GyroValues set handle $GyroValues(handle) set intValue [bno055 readRegister $handle grv,data,$axis] piio usleep 10 return [format {%8.3f} [expr {$intValue / $GyroValues(divisor)}]] } proc ClearHistory {} { global CurrentValue set CurrentValue(history) {} } ................................................................................ after cancel $GyroValues(afterId) } set GyroValues(afterId) [after [expr {$GyroValues(rate) * 10}] ReadGyro] ## ## Read the GYROSCOPE ## set CurrentValue(x) [GryoAxisGeading x] set CurrentValue(y) [GryoAxisGeading y] set CurrentValue(z) [GryoAxisGeading z] } proc LogValues {} { global GyroValues CurrentValue if {[info exists GyroValues(logId)]} { after cancel $GyroValues(logId) } set GyroValues(logId) [after [expr {$GyroValues(freq) * 100}] LogValues] set timeStamp [clock format [clock seconds]] .main.history.data insert {} end -values [list $timeStamp $CurrentValue(x) $CurrentValue(y) $CurrentValue(z)] } proc StartReading {} { global i2cbus dIMUaddress range GyroValues if {$dIMUaddress eq {}} { return ................................................................................ } .main.controls.buttons.start configure -state disabled .main.controls.buttons.stop configure -state normal set GyroValues(handle) [::twowire twowire $i2cbus $dIMUaddress] StartGyro $GyroValues(handle) $range ReadGyro LogValues } proc StopReading {} { global GyroValues if {[info exists GyroValues(afterId)]} { ................................................................................ -increment 10.0 \ -format {%3.0f} \ -wrap no \ -command [format {set ::GyroValues(rate) [expr {entier([%1$s get])}]} $w.rateEnt] $w.rateEnt set 50.0 ttk::label $w.rateLbl2 \ -text { in microseconds} ttk::label $w.frequencyLbl1 \ -text {Logging Rate:} ttk::spinbox $w.frequencyEnt \ -from 1.0 \ -to 1000.0 \ -increment 10.0 \ -format {%4.0f} \ -wrap no \ -command [format {set ::GyroValues(freq) [expr {entier([%1$s get])}]} $w.frequencyEnt] $w.frequencyEnt set 1.0 ttk::label $w.frequencyLbl2 \ -text { in seconds} ttk::frame $w.buttons ttk::button $w.buttons.start \ -text {Start} \ -width 6 \ -command StartReading ttk::button $w.buttons.stop \ -state disabled \ ................................................................................ ttk::button $w.buttons.reset \ -text {Clear Log} \ -width 10 \ -command {.main.history.data delete [.main.history.data children {}]} grid configure $w.busLbl $w.busCMB $w.addrLbl $w.addrEnt $w.rangeLbl $w.rangeCMB x -padx 2 -sticky ew grid configure $w.rateLbl1 $w.rateEnt $w.rateLbl2 x x x x -padx 2 -sticky ew grid configure $w.frequencyLbl1 $w.frequencyEnt $w.frequencyLbl2 x x x -padx 2 -sticky ew grid configure $w.buttons -columnspan 7 -sticky ew -pady 3 grid configure x $w.buttons.start x $w.buttons.stop x $w.buttons.reset x -sticky ew grid columnconfigure $w.buttons {0 2 4 6} -weight 1 grid columnconfigure $w 6 -weight 1 } |
| > > > > > | < | > > > > > > > > > | | | | | | < > | | < | | | | | | | | | | | | | |
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 ... 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 ... 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 177 178 179 180 181 182 183 184 185 186 187 188 189 190 ... 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 ... 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
array set GyroValues { 250dps 0x00 500dps 0x10 2000dps 0x30 250dps,divisor 128.0 500dps,divisor 64.0 2000dps,divisor 16.0 divisor 16.0 full_scale_range 0x30 gryo,x,axis 0x14 gryo,y,axis 0x16 gryo,z,axis 0x18 rate 50 freq 10 } set i2cbus 1 set dIMUaddress 0x28 set range 2000dps set CurrentValue(x) {0} set CurrentValue(y) {0} set CurrentValue(z) {0} proc StartGyro {handle range} { global GyroValues ## ## Place the dIMU in configuration mode ## bno055 writeRegister $handle operMode [bno055 getValue OPER_MODE_CONFIGMODE] ................................................................................ ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisGeading {axis} { global GyroValues set handle $GyroValues(handle) set intValue [bno055 readRegister $handle gyr,data,$axis] return [format {%5.0f} [expr {$intValue / $GyroValues(divisor)}]] } proc ClearHistory {} { global CurrentValue set CurrentValue(history) {} } ................................................................................ after cancel $GyroValues(afterId) } set GyroValues(afterId) [after [expr {$GyroValues(rate) * 10}] ReadGyro] ## ## Read the GYROSCOPE ## set x [GryoAxisGeading x] set y [GryoAxisGeading y] set z [GryoAxisGeading z] if {abs($x - $CurrentValue(x)) > 0 || abs($y - $CurrentValue(y)) > 0 || abs($z - $CurrentValue(z)) > 0 } { LogValues $x $y $z } set CurrentValue(x) $x set CurrentValue(y) $y set CurrentValue(z) $z } proc LogValues {x y z} { global GyroValues CurrentValue #if {[info exists GyroValues(logId)]} { # after cancel $GyroValues(logId) #} #set GyroValues(logId) [after [expr {$GyroValues(freq) * 100}] LogValues] set timeStamp [clock format [clock seconds]] .main.history.data insert {} end -values [list $timeStamp $x $y $z] } proc StartReading {} { global i2cbus dIMUaddress range GyroValues if {$dIMUaddress eq {}} { return ................................................................................ } .main.controls.buttons.start configure -state disabled .main.controls.buttons.stop configure -state normal set GyroValues(handle) [::twowire twowire $i2cbus $dIMUaddress] StartGyro $GyroValues(handle) $range ReadGyro } proc StopReading {} { global GyroValues if {[info exists GyroValues(afterId)]} { ................................................................................ -increment 10.0 \ -format {%3.0f} \ -wrap no \ -command [format {set ::GyroValues(rate) [expr {entier([%1$s get])}]} $w.rateEnt] $w.rateEnt set 50.0 ttk::label $w.rateLbl2 \ -text { in microseconds} #ttk::label $w.frequencyLbl1 \ # -text {Logging Rate:} #ttk::spinbox $w.frequencyEnt \ # -from 1.0 \ # -to 1000.0 \ # -increment 10.0 \ # -format {%4.0f} \ # -wrap no \ # -command [format {set ::GyroValues(freq) [expr {entier([%1$s get])}]} $w.frequencyEnt] #$w.frequencyEnt set 1.0 #ttk::label $w.frequencyLbl2 \ # -text { in seconds} ttk::frame $w.buttons ttk::button $w.buttons.start \ -text {Start} \ -width 6 \ -command StartReading ttk::button $w.buttons.stop \ -state disabled \ ................................................................................ ttk::button $w.buttons.reset \ -text {Clear Log} \ -width 10 \ -command {.main.history.data delete [.main.history.data children {}]} grid configure $w.busLbl $w.busCMB $w.addrLbl $w.addrEnt $w.rangeLbl $w.rangeCMB x -padx 2 -sticky ew grid configure $w.rateLbl1 $w.rateEnt $w.rateLbl2 x x x x -padx 2 -sticky ew #grid configure $w.frequencyLbl1 $w.frequencyEnt $w.frequencyLbl2 x x x -padx 2 -sticky ew grid configure $w.buttons -columnspan 7 -sticky ew -pady 3 grid configure x $w.buttons.start x $w.buttons.stop x $w.buttons.reset x -sticky ew grid columnconfigure $w.buttons {0 2 4 6} -weight 1 grid columnconfigure $w 6 -weight 1 } |
Changes to bno055-1.0.0.tm.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 ... 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 ... 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 ... 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
SymDef GYR_AWAKE_DURR 16SAMPLES 1 SymDef GYR_AWAKE_DURR 32SAMPLES 2 SymDef GYR_AWAKE_DURR 64SAMPLES 3 proc getValue {symbolic} { variable Constants return $Constants(CONST,$symbolic) } proc getValue2 {type symbol} { variable Constants return $Constants(CONST,${type}_${symbol}) } proc getSymbol {type value} { variable Constants set binaryValue [format %b $value] return $Constants($type,$binaryValue) } proc writeRegister {handle register value} { variable Registers lassign $Registers($register) page addr type mask ................................................................................ } } dict set registerValues page $page addr $addr [format {%16.16b} $result] } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] highBit lowBit set result [dict get $registerValues page $page addr $addr] set result [string range $result end-$lowBit end-$highBit] set size [expr {1 + $highBit - $lowBit}] scan $result {%b} result } else { set result [dict get $registerValues page $page addr $addr] } if {$type in {B W}} { if {[string index [format "%${size}.${size}b" $result] 0]} { ................................................................................ } } } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] highBit lowBit set size [expr {1 + $highBit - $lowBit}] set result [string range [format {%16.16b} $result] end-$lowBit end-$highBit] scan $result {%b} result } if {$type in {B W}} { if {[string index [format "%${size}.${size}b" $result] 0]} { scan 1[string repeat 0 $size] %b max incr result -$max } ................................................................................ } } namespace ensemble create -subcommands { getValue getValue2 getSymbol readMultipleRegisters readRegister validateHandle writeRegister writeRegisterBlock } } |
> | > | > | > > > > > > > > > > | | > |
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 ... 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 ... 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 ... 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
SymDef GYR_AWAKE_DURR 16SAMPLES 1 SymDef GYR_AWAKE_DURR 32SAMPLES 2 SymDef GYR_AWAKE_DURR 64SAMPLES 3 proc getValue {symbolic} { variable Constants set ucSymbol [string toupper $symbolic] return $Constants(CONST,$ucSymbol) } proc getValue2 {type symbol} { variable Constants set ucType [string toupper $type] return $Constants(CONST,${ucType}_${symbol}) } proc getSymbol {type value} { variable Constants set binaryValue [format %b $value] set ucType [string toupper $type] return $Constants($ucType,$binaryValue) } proc getShortSymbol {type value} { variable Constants set binaryValue [format %b $value] set start [string length $type] incr start set ucType [string toupper $type] return [string range $Constants($ucType,$binaryValue) $start end] } proc writeRegister {handle register value} { variable Registers lassign $Registers($register) page addr type mask ................................................................................ } } dict set registerValues page $page addr $addr [format {%16.16b} $result] } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] highBit lowBit set result [dict get $registerValues page $page addr $addr] set result [string range $result end-$highBit end-$lowBit] set size [expr {1 + $highBit - $lowBit}] scan $result {%b} result } else { set result [dict get $registerValues page $page addr $addr] } if {$type in {B W}} { if {[string index [format "%${size}.${size}b" $result] 0]} { ................................................................................ } } } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] highBit lowBit set size [expr {1 + $highBit - $lowBit}] set result [string range [format {%16.16b} $result] end-$highBit end-$lowBit] scan $result {%b} result } if {$type in {B W}} { if {[string index [format "%${size}.${size}b" $result] 0]} { scan 1[string repeat 0 $size] %b max incr result -$max } ................................................................................ } } namespace ensemble create -subcommands { getValue getValue2 getShortSymbol getSymbol readMultipleRegisters readRegister validateHandle writeRegister writeRegisterBlock } } |