The Alternate DC board for AudioScope.sh.


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) The Alternate DC board for AudioScope.sh.
# 8  
Old 06-24-2015
Hi bakunin...
Thanks I will use that method in future code.
I used what I knew would work as my starting point but I wanted a lookup array instead and Don gave me what I wanted...

Don...
I was aware of $V remaining and I will take any errors into account by initialising $V to 0 per call. I will initialise $num too and ensure that is always present.
I will be using a _re-usable_variable_ for $V as once it has been used it will not be needed again until the routine is called and can be used elsewhere. (yeah I know try not to use re-usable variables, but I only have 4 and I know what they are and commented on them inside AudioScope.sh)...

Thanks muchly for tour guidance...

Bazza.
# 9  
Old 06-24-2015
Quote:
Originally Posted by bakunin
Oh yes, he's a wiz, isn't he?

Speaking about your earlier code, which you won't need any more but might be interested in anyways:

Code:
if [ $num -ge 100 ] && [ $num -le 199 ]

What you do here is: call /usr/bin/test with the arguments "$num -ge 100" and - if this returns TRUE - call /usr/bin/test again with the arguments "$num -le 199". You can save one open process by calling test once instead of twice because test is able to do logical calculations itself:

Code:
if [ $num -ge 100 -a $num -le 199 ]

You can even manipulate operator precedence by using brackets:

Code:
if [ \( $num -ge 100 \) -a \( $num -le 199 \) ]


I hope this helps.

bakunin
The test -a and -o binary operators aren't required on all POSIX systems (but are currently required on a UNIX branded systems). With some expressions -a and -o can lead to ambiguities in the grammar; so they are likely to be deprecated in the next revision of the POSIX standards. (That doesn't mean that they'll every actually be removed from the shells, but the shell developers all advise against using them.)

Fortunately, test and [ are built-ins in current shells so you don't actually have to fork and exec /usr/bin/test twice so the penalty for using test twice isn't nearly as high as it was in early shells.

On OS X (which is what wisecracker is using), both bash and ksh support the command:
Code:
if [[ num >= 100 && num <= 199 ]]

which is handled as part of the shell's grammar, not as a built-in utility (which makes it even faster and gets rid of the ambiguity in the test syntax). This form isn't in the standards yet, but is also likely to be added in the next revision.
This User Gave Thanks to Don Cragun For This Post:
# 10  
Old 06-25-2015
Right guys...

The code below is a working example of the real DC voltage input with the output read off of a professional frequency counter. (The builtin counter inside AudioScope.sh works just as well but I needed to work out the calibration method so I tested the board on the bench at work. [ Shhhh, don't tell anyone... ;o) ]
The values of '$freq' were rounded up or down to the nearest 0 or 5...
The board has had one very minor modification, a 1M resistor added.
The code below is working a dream, thank you Don...
A highly mofified version will be incorporated into the main code over the WE...
Code:
#!/bin/bash
# lookup
freq=( 0 860 945 1025 1110 1190 1275 1355 1445 1520 1605 1685 1770 1855 1940 2025 2110 2200 4000 )
voltage=( 0.000 0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 1.125 1.250 1.375 1.500 1.625 1.750 1.875 2.000 0.000 )
while true
do
	read -p "Simulate frequency from AudioScope builtin counter, 0 to 3999:- " num
	for ((i=0; i < ${#freq[@]}; i++))
	do
		[ "$num" -lt ${freq[i]} ] && break
	done
	[ $i -gt 0 ] && [ $i -lt ${#freq[@]} ] && V="${voltage[$i]}"
	echo "$V Volts DC..."
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. OS X (Apple)

AudioScope Project.

AudioScope Project. (Apologies for any typos.) For the few following...... AudioScope.sh... Now at Version 0.60.00. Well this baby has come a long way since its inception in January 2013. It is now at Version 0.60.00. It is MUCH more Apple centric now with a new OSX Sierra minimum _silent_... (7 Replies)
Discussion started by: wisecracker
7 Replies

2. UNIX for Advanced & Expert Users

Has AudioScope found a bug in bash 4.4.5?

Using AudioScope.sh on Ubuntu 17.04 from a live DVD disc I came across an error. Consider the code below it is a MUCH shortened version of the KEYBOARD input in AudioScope. #!/bin/bash bash --version uname -a status=0 KEYBOARD() { read -r -p "Enter QUIT or EXIT to quit:- " kbinput if ||... (11 Replies)
Discussion started by: wisecracker
11 Replies

3. OS X (Apple)

The DC Control and Timer boards for AudioScope.sh...

Hi all... Apologies for any typos... For those intersted in the AudioScope the next construction is finished. I have not been totally idle but working out the hard stuff to be able to be very simple to build. It is a single transistor simple timer that lasts for about 1.2 to 1.8 seconds.... (2 Replies)
Discussion started by: wisecracker
2 Replies

4. What is on Your Mind?

AudioScope...

Boy oh boy, with only a MONO mic input to use AudioScope gets much more difficult when the ALTDC board is included. It needs, so far, two hits at the MIC input with a single hit at the HEADPHONE audio output. The first at the highest practical resolution for the AC component and the second... (0 Replies)
Discussion started by: wisecracker
0 Replies

5. How to Post in the The UNIX and Linux Forums

Board not present

Can please somebody tell me what could be the reason for the following error (Unix Motorola Server): /usr/etc/ce3/s374: Board at address 0xff10000 not present - Entry skipped. /dev/lpc2: I/O error I already replaced the board 374 on the server, but I have the same problem. Thank you! (1 Reply)
Discussion started by: dma
1 Replies

6. Shell Programming and Scripting

Experimental awk audio converter for CygWin and AudioScope.sh

Development machine:- Standard MBP 13 inch, OSX 10.7.5... GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11) Copyright (C) 2007 Free Software Foundation, Inc. Scenario:- Audio capture for AudioScope.sh for CygWin without ANY third party installs. I am trying my hardest to get a... (6 Replies)
Discussion started by: wisecracker
6 Replies

7. OS X (Apple)

AC to DC trigger pulse for AudioScope.sh.

Hi all... Has _below_ ever been done in UNIX shell scripting before? (I have done this easily in Python but this is using purely the shell.) The DEMO version IS built and has been tested. Pre-amble... I now need at least one control pulse for the AudioScope.sh when in PURELY audio I/O mode,... (2 Replies)
Discussion started by: wisecracker
2 Replies

8. What is on Your Mind?

AudioScope has had a magazine review. <shock>

Hi Admin and Staff... Thanks for hosting AudioScope.sh on this site. I have had the biggest surprise of my life today. This months issue of the UK Linux magazine "Linux Format" have done a small piece on the project. Issue April 2014, LXF 182, page 65... This I never expected and I... (1 Reply)
Discussion started by: wisecracker
1 Replies

9. Post Here to Contact Site Administrators and Moderators

Board Maintenance

Just a remark now the board has grown to considerable proportion. I see too little of an active hand(s) maintaning the boards, clipping away dead posts, moving posts that were created in the wrong forums etc. It's a bit tiring to see alot of threads ending in: this has been covered before, do a... (7 Replies)
Discussion started by: patvdv
7 Replies
Login or Register to Ask a Question