I’m interested too in why board boots with IO pins 1-10 (or 0 to 9!) as Inputs (safer I would assume), yet I still measure 3v3 coming from them in this default state, with enough current to make a connected LED glow dimly
Because, as the manual states: they have 4.7K pull-ups.
That makes it easier to make end-stops: the user only has to add a switch.
More usual are pull-up value in the range of 20k-47K, but in a 'motor' environment I decided for a bit more pull as it is less susceptible to noise.
Therefore you see the LEDs "glow" more then with other boards.
When I turn pins to Output and state Low, LEDs don’t light up which is the way Raspi GPIO pins work too.
As to LED ON or OFF when you set your bit high/low: that depends on how you connect your LEDs.
LED+R between VCC and PIN: you get the inverse mode: pin high is LED off.
LED+R between PIN and GND: you get the true mode: pin high is LED on.
Can we please have as well a way to change individual Pin states as the GUI can do this and so the board clearly can
In fact: the GUI does not control individual pins. It 'remembers' the state of all pins and AND-es or OR-es the new pin into it.
Assume 'pin_state' holds the high or low state of all output pins.
Then to set a pin X high:
pin_state |= (1<<X);
gb.set_output_pin_state(0,pin_state)
To set pin X low:
pin_state &= ~(1<<X);
gb.set_output_pin_state(0,pin_state)
The exor operator '^' can be used to toggle to the reverse state:
pinstate ^= (1<<X);
This is code taken from the 'toast-e' control program.
It is written in C but has the same and-or structure.
The 'pin_state' is here named 'mouth' the ')' command toggels the 'mouth' state on and off.
I first read the bit and check if it is on or off. Then I change it to the opposite value.
The exor operator '^' can be used for pure toggle_to_reverse_state control.
Code: Select all
case ')' : // Smile on/off
if (mouth & MOUTH_SMILE_BIT)
{ // is on: switch off
mouth &= ~MOUTH_SMILE_BIT;
}
else
{ // set smile on requires middle on too
mouth |= (MOUTH_SMILE_BIT | MOUTH_MIDLE_BIT);
// disable potential frown
mouth &= ~MOUTH_FROWN_BIT;
}
set_output_pin_state(BOARD,mouth);
I Just can't get my head around the raw commands in the GUI log
Beware that send_raw was never ment to be used other then in extreme cases.
I only use it to send commands which are WRONG so I can check if the error detect system works.
It sends the bytes AS-IS to the board thus you must make sure the command is preceded by the start-command byte and finished with one or more end-command bytes
and that it has the
exact right number of bytes. If the latter is wrong it may confuse the internal FSM so that your next command is lost as well.
In order to understand the raw commands in the GUI log you have to read the command section of the maual. The drivers are there so you don't have to.
The log RAW commands are usefull for replaying command so
you can use the board without having to know anything about programming!
(See
https://www.youtube.com/watch?v=_UTNJ79 ... e=youtu.be)