From: DE U. G. D. <dde...@en...> - 2012-07-17 14:04:00
|
To the Fimata developpers, I am Diego de Uña and I am working in a project with Clement Quinson and Pierre Boutillier at Planete Sciences (a french associations to promote the science among the young people). We are working in a project consisting on controlling robots through a Squeack virtual machine communicating with an Arduino board. Therefore, we are using Arduino UNO boards and the Adafruit Motorshield to control DC motors. Since the H-bridges of the motorshield are controlled by a shiftregister we have decided to implement one of the proposals on Firmata for shiftOut registers. At the beginning we though that implementing the second proposal (a config message and then a data message) would be better to avoid sending the same information several times. Nevertheless, this implementations needs to save the configuration somewhere and since we don't know how many shift register the user want to connect, it means we have to use dynamic array to save the configuration. Also, we would have needed to crate a structure representing each shift register containing each information (latch pin, clock pin, data pin etc...) and verify each time if a shift register is already configured or not (by checking each structure of the array). In my opinion it doesn't worth it (too complex). On the other hand, the first proposal is easier to implement and don't need to define the SHIFT_CONFIG macro. Also, we can avoid using structures or arrays. Anyway, in my implementation I use 3 integers (of 64 bits) to remember what pins have already been configured as outputs (but I think it might be optional since setting a pin as an output doesn't take too much time). Finally I have decided to implement this proposal. So, I have implemented a function of prototype: void shiftRegister_tx (byte argc, byte mesg []). mesg is an array containing the frame of bits corresponding to the shiftOut message: SYSEX_START (0xF0) SHIFT_DATA (0x75) dataPin -> mesg[0] clockPin -> mesg[1] latchPin -> mesg[2] msbFirst -> mesg[3] other data -> mesg[4........n] SYSEX_END (0x7F) argc is the size of mesg. This function configures the pins as outputs, and send the message (using the standard shiftOut function of Arduino's library) to the shift register. I have tested it with an AdafruitMotorshield and works perfectly (sending as much data as wished). Also, I have been thinking of implementing a shiftIn function to read on the shift register, but it seems more complicated to me because there are many things that could depend on the size of the shift register. Could we imagine to use it as a beggining to implement the feature in "master" ? I look forward to hearing from you. -- Diego de Uña ENSEIRB-MATMECA I2 ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |