2012a simulink arduino, fast timer, DHT22

I am using the Simulink R2012a interface with arduino. I am currently not using the embedded coder. I am trying to interface with a humidity temperature senser, DHT22. It has it's own interface, I found some arduino C libraries. It is a one wire interface, not the standard. Every 2 or so Seconds I plan to read from this sensor. To read the sensor I follow this pattern
1. Pull signal low for greater than 500us. -> 2. Pull signal high for 20-40us. -> 3. Sensor pulls data low for 80us. -> 4. Sensor pulls data high for 80us. -> 5. Then comes the transimission of data (If a high pulse is less than 30us it is a 0) (If a high pulse is 30 - 70 us than it is a 1)
So I have to read and write a pin in 10s of useconds. So I guess my question is how can I read and write an I/O pin that fast in simulink?

Answers (1)

You cannot read an I/O pin that fast in Simulink itself. You might be able to do it with some mex code, but I believe that would be too slow as well.
It sounds to me as if what you should be doing is triggering an arduino sketch that does the work.

3 Comments

Is there a way to import C code to do it? What is an arduino sketch? Sorry I am new to this. Or is the only way it will work is if I use the embedded coder and add the DHT22 code later? I don't have embedded coder on my computer, but I can use a lab computer that has it. What is the fastest time simulink can model, for model deployment for stand-alone operation on the arduino?
http://arduino.cc/en/Tutorial/Sketch
"A sketch is the name that Arduino uses for a program. It's the unit of code that is uploaded to and run on an Arduino board. "
Thanks. Is there a tutorial for triggering a sketch in simulink?

Sign in to comment.

Categories

Asked:

on 12 Apr 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!