Comments (19)
The first step is to get a one-wire library in the Arduino core. An alternative is to write a one-wire library that could be included with Firmata, but this would have to be a library that no one is currently using or they'll have collisions (this is something the Arduino IDE needs to sort out at some point... allowing a user contributed library to override a core library of the same name).
A one-wire library (or any library for that matter) used with Firmata needs to be non-blocking. There cannot be any delay statements (unless only a few microseconds). This is critical to enable other features such as the ability to read analog inputs or send and receive digital i/o in a timely manner. A delay from on library should not block the general functionality of basic I/O in Firmata.
If someone want's to take this on:
- Add a one-wire proposal to the Proposals page on the firmata wiki: http://firmata.org/wiki/Proposals. You will need a configure definition to set up the pin and you'll need a read/write definition to send and receive data. Look at some of the existing protocol definitions for inspiration.
- A new pin type will need to be added to Firmata: ONEWIRE = 0x07
- Submit a request (http://code.google.com/p/arduino/issues/list) for a one-wire library to be added to the Arduino core for a future release . If a non-blocking one-wire library does not exist, create one (test the hell out of it) and submit a pull request to the Arduino project on github: https://github.com/arduino/Arduino.
- Implement one-wire support in StandardFirmata by wrapping the one-wire library.
- Test with several one-wire devices.
- Test with a one-wire device while reading analog input, digital i/o and other firmata features.
from arduino.
Great that you copied it here.
Sorry for offtop,
Arthur.
from arduino.
I've started investigating how to add support to OneWire and my aim is to come up with a fork this week. At a glance the library makes use a few micro seconds delay, being 300micro seconds the longest one.
As a next step, I will need to control a ph sensor from atlas scientific, which isn't very popular nor open source.
How do you suggest to add support for this kind of device?
from arduino.
I just thought about using Dallas DS18B20 one-wire digital thermometer http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf .
from arduino.
For custom or otherwise proprietary sensors you'll want to use the sysex message format (as described in my last reply on the dev list). For one-wire a good first step is to use the existing OneWire library and create a new firmata sketch for it using StandardFirmata as a base. That will at least produce something that can be used for testing. I2C support was provided (and widely used) outside of StandardFirmata for a couple of years before it was added to StandardFirmata. It's actually easier to distribute custom Firmata implementations because they are not dependent on the Arduino update cycle.
from arduino.
Link to this discusion on dev list: http://sourceforge.net/mailarchive/forum.php?thread_name=CAFhP_FKF1P0uPUTApw5uQJ6%2BPh94T7mjJBw%3DyqY1DrgiMetV3w%40mail.gmail.com&forum_name=firmata-devel .
from arduino.
I've recently started to implement OneWire-support in Firmata.
See https://github.com/ntruchsess/arduino/tree/master/examples/OneWireFirmata
and my works on perl-firmata (which also has initial support for OneWire): https://github.com/ntruchsess/perl-firmata/tree/master/lib/Device
from arduino.
I've never used (nor do I own) any devices that use the one-wire protocol, so I'm not the best person to give feedback about your one-wire implementation. However there are a couple of things I suggest you do differently:
Try to use Firmata.sendSysex() rather than a series of calls to Serial.write(). By using sendSysex, each byte you send will be split, but it will make your file more readable and it will make parsing on the client side more predictable since you'll know to always join bytes in pairs.
Extract lines 278 - 294 to a function. This will make loop easier to read, especially if your one-wire code is merged into StandardFirmata at some point in the future.
Add your proposal for a firmata one-wire protocol to this page on the wiki:
http://firmata.org/wiki/Proposals
from arduino.
Hi Jeff, thank you for your feedback.
I worked on scheduling series of arbitrary oneWire-commands including delays in a non-blocking manner. This can be used to report data from arbitratry oneWire devices. Works allready pretty well.
See:
https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/OneWireScheduler.cpp
The problem I'm facing is that even quite simple tasks do not fit into a single sysex-messag (e.g. reading a ds18b20 thermometer requires to go through reset->select->write->delay->reset->select->write->read), which is caused by the 2-bytes per 8-bit bytes encoding plus the limitation of 32bytes per message in Firmata which effectivly reduces the number of 8-bit bytes per sysex-message to 15. (Which is the primary reason of why I don't like to use the Firmata.sendSysex()-method in this case).
When not using two 7-bit values to encode 1 8-bit byte but pack 7 8-bit bytes into 8 7-bit values it is possible to send 27 bytes per sysex-message. I've implemented the algorithm to pack and decode data this way, which lessens the space-constraints a bit.
See https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/FirmataExt.cpp
Unfortunally 27 bytes is still not enough for most OneWire command-sequences, so I have to figure out a way to reliably send and receive more sysex-messages in a row.
I'll add a proposal to the wiki as soon I feel it fullfills all my needs in this respect.
regards,
Norbert
from arduino.
I didn't know OneWire data packets were so large. I'm assuming then that the data packet specific a particular OneWire device can exceed 32 bytes. We could probably increase the 32 byte limitation in Firmata as well. I'll have to read up on OneWire.
Also regarding the scheduler. It would be great to have a general purpose scheduler in Firmata.
from arduino.
"can exceed 32 bytes" - maybe it should be configurable to not consume to much of RAM
Some time ago I wrote my own Task Manager with scheduler and future (possibly cyclic) tasks but I wonder if there is any "general purpose scheduler" for Arduino?
from arduino.
1-wire devices typically have a 'scratchpad'. That's a read- and writable area of (from what I have seen) up to 32 bytes in size being used as communication buffer. A One-wire-device has an unique identifier of 8 bytes. Plus some bytes to identify the sysex-messagetype and One-wire command to execute. That's aprox. 40-50 bytes of payload. This would fit into 57 bytes of sysex-message if being packed dense (8 characters of 7 bit per 7 Bytes of payload).
So increasing the maximum message size to e.g. 64 bytes should be sufficient.
Regarding a general purpose scheduler: I'm gonna change my onewireScheduler so it stores and schedules sets of midi-messages to trigger anything that firmata supports (plus some addons like pauses and reschedule the same set).
from arduino.
here we go: refactoring of the generic scheduler is done:
https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/FirmataScheduler.h
https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/FirmataScheduler.cpp
it allows to create tasks containing series of any firmata-midi-messages to be replayed later.
OneWire message-format is optimized for flexibility and size. A single message may optionaly trigger a onewire-reset, select, write and read (plus an optional delay and reshedule if being added to the scheduler as a task), so it's possible to trigger an a/d-convertion and read the result with just 2 messages.
https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/OneWireFirmata.h
https://github.com/ntruchsess/arduino/blob/master/examples/OneWireFirmata/OneWireFirmata.cpp
Next I'll write up the message format used as a proposal on firmata.org.
Comments?
from arduino.
Please also post this to the firmata dev list. There are people on the list who are likely not following the issues on github. You may want to add a little more explanation about the general purpose scheduler. I think this could be really useful.
from arduino.
proposal of scheduler and onewire is in the wiki: http://www.firmata.org/wiki/Proposals
from arduino.
I've merged the implementation with the StandardFirmata code and all pending changes from dev branch:
https://github.com/ntruchsess/arduino/tree/master/examples/OneWireSchedulerFirmata
For anyone willing to test: perl-firmata is also updated to support everything included in this version:
https://github.com/ntruchsess/perl-firmata
so how to proceed now?
from arduino.
I put the put OneWireShedulerFirmata into it's own branch separating it from changes I had previously merged from 'dev' branch to easy merging with master.
https://github.com/ntruchsess/arduino/tree/onewire_scheduler/examples/OneWireSchedulerFirmata
from arduino.
also see #43
from arduino.
As OneWire is integrated into ConfigurableFirmata for 8 month now I'm closing this one
from arduino.
Related Issues (20)
- Analog pin as digital. HOT 3
- Analog Pins on Constant Voltage HOT 1
- Additional Firmata Java library
- Inconsistent state for additional analog pins (A6 - A11) on Arduino Leonardo HOT 1
- Pyfirmata and arduino leonardo mouse and keyboard abilities HOT 2
- T HOT 1
- Error compiling for board Arduino Uno. HOT 1
- Error compiling Firmata for board Arduino Nano Every HOT 8
- Error when compiling StandardFirmata 2.5.8 for Ardbox Analog HF + Wifi from Industrialshields HOT 2
- broken link in readme.md
- Last released version is from 2018 despite a lot of new work being merged HOT 10
- How to change TX RX pin for Nano HOT 3
- To drive a Servo what Capabilities do i need from a board? HOT 2
- Ethernet server mode versus client mode HOT 1
- Arduino HOT 1
- Arduino Nano Every doesn't report A6 and A7 on StandardFirmata HOT 3
- add Arduino UNO R4 MINIMA to boards.h please HOT 11
- [Question] How to add support for Jolly-dev to StandardFirmataWiFi HOT 9
- Firmata for Raspberry Pi Pico HOT 1
- Problem compiling firmata for Giga R1 Wifi board HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino.