Hi folks
I am teaching myself Python by working through Hans Petter Langtangen's excellent book "Primer on Scientific Programming in Python".
The exercises in chapter 4 of the book require the student to use Python with the freely downloadable tools MatplotLib and SciTools to plot graphs of mathematical functions.
Despite downloading and installing numerous different versions of Python 2.x, MatPlotLib...
User Profile
Collapse
-
Req: Python 2.x incompatibility with MatPlotlab & SciTools
-
Thanks Rabbit
Is there any way to calculate the values for the commercial E-series by formula without resorting to writing each element for each series in the form of multiple lists or dictionaries?
Thanks!
DaveLeave a comment:
-
Req: Calculating Preferred Values ("E Series") for electronic components
Hi Folks!
I was trying to write some Python script to calculate resistor values for electronics projects, and wanted to generate lists of the preferred resistor values in each standard commercially available ranges of values (E6, E12, E24 etc.) by formula rather than using large unwieldy lists or directories..
From what I've been able to find by reading & Googling, the "E series" of preferred values are... -
Many thanks for this - much appreciated.
Now you've explained how to do it, it seems obvious!
Best wishes
DaveLeave a comment:
-
Hi again!
With the second routine, if a user enters a negative number or a non integer, the isdigit() command detects "." or "-" as non digit characters, and so returns the error message "You entered an alpha character..."
I've tried converting the code to Python 3 and using the isnumeric() function, but this does not return "True" if the string contains "." or "-"...Leave a comment:
-
Many thanks Bvdet
These routines do exactly what I needed.
They also have taught me some very useful new techniques, so will study these for future reference.
Best wishes
DaveLeave a comment:
-
Hi Bvdet
Many thanks for your help - much appreciated
3 further thoughts / queries:
1)
I was wondering if it is possible to go one step further, and make this module completely customisable for repeated use by somehow passing logical arguments (as strings) to define module parameters for error detection.
e.g. so that I could call the module from one point in main() as:
getdata('...Leave a comment:
-
Req: Error Trapping / Data Validation
Hi!
I'm a beginner using Python 2.5
I'm trying to write a module which will peform the function of data entry and error trapping.
If the user enters an integer outside of a pre-defined range or tries to enter an non-integer value, the module will ask to re-enter until a correct response is made.
I want to call the module repeatedly with different sets of parameters for allowable data range... -
Thanks again bvdet!
Really appreciate you taking the time to help out with my queries.
Have a great weekend!
Best wishes
DaveLeave a comment:
-
Many thanks for the rapid reply.
I got the whole thing working last night using the quick & dirty "master string" technique described above, and it seems to work fine - I can now send and receive data from the flow meter at user-defined intervals, and save the result as a .csv which opens in Excel :-)
A few quickie related questions:
1) How long can a single string can be before it causes problems?...Leave a comment:
-
Req: ? Python command to append data to file
Hi
This is my first attempt at writing Python script - it's probably a bit ambitious, but there again, whatever doesn't kill you makes you stronger... ;-)
I'm trying to write a script for a datalogger, which will import data from a laboratory flow meter at regular user-defined intervals via a serial port connection, then save it as a CSV file which can then be opened in Excel for analysis.
The imported... -
Hi again
I think the problem was a conflict on accessing COM1 due to a combination of both Hyperterminal & Windows Automatic Updates running in the background, and also the Serial Port Monitor being opened in the wrong sequence, before the USB dongle was connected. D'Oh!
Am now up and running again :-)
If I get the rest of the code written, I'll post it to the group in case it is of help to anyone working on a similar project....Leave a comment:
-
Hi
Thanks for the advice & links to the documentation.
Ports open and close the in serial monitor, but no data transferred in either direction, and PySerial seems to be unable to access COM1 any more - not sure why.
Have tried rebooting the laptop, disconnecting/re-inserting USB dongle & flow meter. No joy :-(
Any suggestions welcome!
Thanks
Dave
PySerial output:
>>>...Leave a comment:
-
.. also, when I was accessing the meter via Hyperterminal, the ASCII command string "DCFTP0001" <CR> would instruct the meter to send back an 18 byte string of characters corresponding to the flow rates that I am trying to log. This worked fine.
However...
When I replace the ASCII sequence to check communication in my Pythonscript:
se.write("?\r")
...with the command to request data:
se.write("DCFTP 0001\r")...Leave a comment:
-
Many thanks!!
Now the parentheses are in place, the data is sent to the monitor fine...
In order to receive the reply from the monitor, I had to increase the se.timeout parameter to 4 to allow time for the monitor to respond and send a return signal. Not sure whether this is the proper way to do things, but it seem to work.
Is there a neater way of writing all of the port initiallisation parameters, so they're all in a set...Leave a comment:
-
RS232 data transfers OK with Hyperterminal, but not with PySerial
Hi
I'm a Python newbie trying to write a datalogger to acquire data from a laboratory meter using RS232.
Hardware: Samsung N100 laptop. Maplin's USB-Serial converter dongle. TSI 4100 series laboratory flow meter
Software: Windows XP. Python 2.5 & IDLE interface. HDD Free Serial Port Monitor 3.31. Hyperterminal Private Edition v5.0 (Drivers for USB dongle installed, Windows firewall exception made for...
No activity results to display
Show More
Leave a comment: