View Single Post
  #10   Spotlight this post!  
Unread 02-06-2002, 01:46
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Actually, I've been thinking.... they give us control over one byte. That means we can send either 8 digital outputs to the dashboard, or one 0-255 output...

If the 0-255 method is done by having
bit 0 = 1
bit 1 = 2
bit 2 = 4
bit 3 = 8
bit 4 = 16
bit 5 = 32
bit 6 = 64
bit 7 = 128
then turning on/off the appropriate bits to get any number from 0-255 (1+2+4+8+16+32+64+128 = 255), couldn't this method also be used to get two numbers from 0-15? Meaning....
bit 0 = 1
bit 1 = 2
bit 2 = 4
bit 3 = 8
bit 4 = 1
bit 5 = 2
bit 6 = 4
bit 7 = 8
So, using this method, we could program the Robot Feedback byte to actually carry two PWM values, but just the PWM value ±16. Since the maximum value is 255, if we divide it by 16, we get a number between 0 and 15. Thus, we could send to a dashboard program approximately two PWM values.

Say the code outputs a value of, oh, 123 to a pwm. We can take 123 and divide it by 16. Since PBASIC doesn't handle decimals, the final result would be 7 (it's actually 7.6875). This number will always be between 0 and 15, so we could use bits 0 through 3 to 'encode' it (bit 0 - on; bit 1 - on; bit 2 - on; bit 3 - off; 1+2+3 = 7). The same could be used with bits 4-7.

In the end, the dashboard program would read the Robot Feedback (LED) byte and from it, decode two numbers between 0 and 15 - or, two PWM outputs to the nearest 16. Sure, it's not perfect, but it's an approximation of what your robot code is sending out to the PWM.

This method could also be used to transfer to a dashboard program an approximate PWM value AND 4 digital outputs.

You guys understand what I'm trying to say?
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies

Last edited by DanL : 02-06-2002 at 01:48.