Open arfoll opened 8 years ago
So the best I have is that firmata_pull doesn't seem to ever pull anything, however if I use firmatajs it works well. I got a little further by enabling VMIN=1 on the tty and started getting alot of garbage but still didn't get the 'ready' signal.
Hello @arfoll I'm sorry I don't have much time in this month to check your problem. Maybe there is an issue. Please continue writing here if you find anything.
No problem - just posted this in blind hope :) I'm working with a Genuino 101 so maybe that's my problem, I've made it work (kindof) now, instead of 14 you have to ask for 0 for A0 interceptty is working really well for debugging this, I get the feeling part of the issue is the way the serial.c sets up the serial port, it works without any issues from firmatajs and I still don't really understand why.
HI Both,
First let me congratule you Mr. Dourlens for this library. I think its a nice work and it took me a while to find a nice library for C and Firmata. I have the same problem than arfoll using Arduino UNO. I wrote it in this way:
int MY_PIN = 0; firmata_pinMode(firmata, MY_PIN, MODE_ANALOG); firmata_pull(firmata); int output = firmata->pins[MY_PIN].value ;
This is what I understood based on the available documentation. However, I had the same doubt about A0 (pin 0 vs 14) and seeing that there was no signal I decided to do for loop to scan pins. All pins return 0.
Thanks is advance.
All the best,
CLP
Keep pulling, you've only just started receiving sysex messages you can't guarantee the next one is what you want (check with gdb when you get it in firmata_parse if you want). It's 14 for aio0.
FYI I used firmatac as the basis for intel-iot-devkit/mraa reading code in src/firmata/firmata_mraa.c to see how I call it that may help. I also modified firmata.c to do some i2c. On 5 Jun 2016 01:43, "pastranacl" notifications@github.com wrote:
HI Both,
First let me congratule you Mr. Dourlens for this library. I think its a nice work and it took me a while to find a nice library for the C and Arduino. I have the same problem than arfoll using Arduino UNO. I wrote it in this way:
int MY_PIN = 0; firmata_pinMode(firmata, MY_PIN, MODE_ANALOG); firmata_pull(firmata); int firmata->pins[MY_PIN].value ;
This is what I understood based on the available documentation. However, I had the same doubt about A0 (pin 0 vs 14) and seeing that there was no signal I decided to do for loop to scan pins. All pins return 0.
Thanks is advance.
All the best,
CLP
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jdourlens/FirmataC/issues/2#issuecomment-223786371, or mute the thread https://github.com/notifications/unsubscribe/AAfZZh3_uG9LxjsxHBL3lEhQs6Gcb3syks5qIhukgaJpZM4HcJWB .
Thanks for the fast answer @arfoll. First let me admit that my knowledge of i2c and hardware programming is almost null. I took a look at your mraa codes. I found your function for analog reading but because it calls to mraa_uart_write and this itself to others, it would a mess to me, because I have already implemented the codes for other functions using @jdourlens' FirmataC. I'm aware that someone with more experience and knowledge could extract how to split Firmata's messages to extract the analog value based in both codes.
Following your suggestion I included a calling to this function in a while loop
if ( firmata->pins[pin].mode != MODE_ANALOG ) firmata_pinMode(firmata, pin, MODE_ANALOG); firmata_pull(firmata); firmata_pinMode(firmata, pin, MODE_ANALOG); return firmata->pins[pin].value;
The returned values are always 0. Surprisingly, for every calling of the function, it is printed Setting pinMode at: 0 with value: 2
Could this be the problem? By some reason the analog pin is not set to MODE_ANALOG. Or the state of the pin is not determined correctly. BTW: What is the meaning of firmata->pins[14].analog_channel? I always obtain 127 for every pin.
In the end my objective is to obtain in real-time the data in the given analog pin for a measurement apparatus. I did that previously in MATLAB and it worked nice.
Thanks,
Best
I want to read A0 on my board, I'm not entirely sure how this works, and there's no example so was trying to write one. So far I have something like this:
Is 14 A0? or is it 0? And I'm guessing that doing the pull means I update the data available in t_firmata which is what I want but do I need the pinMode call and do I need to do someting else first like register for ADC updates/ask for it? Can I ask for just A0?
Similarly have you got any examples of how someone would do some i2c or spi?