Fw: [Tutor] Continuous input at sample rate

Deirdre Hackett Deirdre Hackett" <deirdrehac@lycos.co.uk
Tue Feb 4 09:57:02 2003


----- Original Message -----
From: Deirdre Hackett
To: tutor@python.org
Sent: Tuesday, February 04, 2003 2:29 PM
Subject: Fw: [Tutor] Continuous input at sample rate



----- Original Message -----
From: Deirdre Hackett
To: alan.gauld@bt.com ; tutor@python.org
Sent: Tuesday, February 04, 2003 2:18 PM
Subject: Re: [Tutor] Continuous input at sample rate


> I want to take information into my program continuously at 20
> samples per second,
>

I didn't understand the rest but to loop 20 times a second
 - provided your machine is fast enough! - do this:

while 1:
   sleep(0.05)  # 1/20s delay
   # do something here
   if someCondition: break


> The command to send to the device is *99c\r
> What do i need to change in regard to just polling the device?

Are you sending or polling(reading)?
Or both? Do you send to get a result back?

I don't understand sorry.

Alan g

Normally I would just poll the sensor i am using by sending *99p\r to the
sensor.
         ser.write("*99c\r")
In response to this command the sensor would output a single sample.
    996   - 3,898   - 7,541
These are the x, y and z components of the strength and direction of a
magnetic field.
I would like to take in continuous readings at the sample rate which is
20sps.
To do this, send *99c\r to the serial port.
The output should send continuous readings to the computer through the
serial port.

Not sure that this clears things up, but it is a start
Thanks,
Deirdre