Home › Evil Mad Scientist Forums › Microcontrollers › Octolively with external sensors; communicate via ISP, or other pins?
- This topic has 4 replies, 2 voices, and was last updated 10 years, 10 months ago by emsfly.
-
AuthorPosts
-
November 5, 2013 at 11:40 am #20266emsflyParticipant
Hi all-
A question I couldn’t find answered; perhaps my search terms were incorrect.
If you have an Octolively system, and would like external inputs (and/or outputs), what is the best way to do this?
You could reprogram the system, via the ISP, but that would leave you with the current sensors. Could you somehow use an Arduino (with its own sensors, inputs, outputs, shields, etc) to talk to the Octolively via that 6 pin connector? I see “Programming interface: Standard 6-pin AVR ISP (ICSP/SPI)”, which sounds like you can use SPI (my own experience has been with I2C, but the idea of using SPI seems like it would work). Have the Arduino handle sensors and other stuff, have the Octolively handle the lights.
Thoughts on this scheme?
November 5, 2013 at 1:01 pm #21493Windell OskayKeymasterYes, the SPI interface is available.
Also, the Octolively already has 8 sensors onboard– to operate those IR sensors –and 5 additional digital I/O lines normally connected to the neighbors. That’s up to 13 lines, 8 analog/digital, 5 digital. Depending what you’re trying to sense, the easiest option may be to repurpose some of the existing lines.November 6, 2013 at 7:47 pm #21494emsflyParticipantMost excellent! Is there a list of commands/example of using the SPI to talk say, from an Arduino?
I see that the lovely USBtinyISP kit is needed to reprogram the Octolively, if needed. Time to procure one posthaste.
Is the source code just what is at github? This does seem to have the current functionality, but don’t see how SPI commands would be interpreted (unless I’m missing something completely here).
https://github.com/oskay/Octolively/blob/master/firmware/octolively.c
I do see that pins PB5, PB6, and PB7 are ‘free’, in that once new code is downloaded, they could be used. If we were to reprogram the Octolively, perhaps those could be used as I/O pins. I see this lovely bit (no pun intended) here in the code, which is hooked up to Pin B5, so a similar piece of code could be used for inputs using PB6 and PB7:
int readButton() {return (! bit_is_set(PINB, PINB5));}I also see:
int receive_from(uint8_t dir)which apparently handles inputs PB1 through 4, but they are used for between board communication. Haven’t *quite* figured out how to configure an output, though. I think I need to look at the code at this point for that, it seems that might be the ticket:
DDRB = ComOutputMask; // All B Inputs except for pin PB0, our output.
PORTB = ComOutputMask | ComInputMask; // Pull-ups on input lines, output line high to start.November 6, 2013 at 8:02 pm #21495Windell OskayKeymasterWhile there is an SPI hardware interface available, there is no software presently implemented to receive commands or codes over SPI– the code would have to be written to do that.
November 6, 2013 at 8:58 pm #21496emsflyParticipantThanks; that’s what I thought.
I think the input stuff can be figured out by a copy/paste of the readButton; just have to figure out how to do output.
A.
-
AuthorPosts
- You must be logged in to reply to this topic.