The Alternate DC board for AudioScope.sh.


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) The Alternate DC board for AudioScope.sh.
# 1  
Old 06-23-2015
The Alternate DC board for AudioScope.sh.

Hi guys...

Well I have entered an area of partial insnity... ;o)
Below is a photo of the 'ALTDC' board for AudioScope.sh...

I have decided to incorporate all three methods for obtaining DC into this MBP via the MIC input.

1) VFO.
2) CHOPPER.
3) COUNTER.

The controller for the COUNTER is not yet done but this board can now do 1) and 2).

I have started properly coding for the VFO section first but and I have decided just to do an accuracy of 4 bit depth for this. That is 0 - +2V to an accuracy of 0.125V.

I have an example basic piece of code that checks ranges of values so as to create each of the 16 values possible. The problem is it is ugly and 16 conditional "if"s is not the way to go. Again I can't find any info how to create a look up table where each lookup is a range of values. The EXAMPLE code below DOES work mighty fine but looks so ugly and primitive.

Any other ideas guys?
Code:
#!/bin/bash
# lookup
while true
do
	read -p "Number, 100 to 499:- " num
	if [ $num -ge 100 ] && [ $num -le 199 ]
	then
		echo "1) $num"
	fi
	if [ $num -ge 200 ] && [ $num -le 299 ]
	then
		echo "2) $num"
	fi
	if [ $num -ge 300 ] && [ $num -le 399 ]
	then
		echo "3) $num"
	fi
	if [ $num -ge 400 ] && [ $num -le 499 ]
	then
		echo "4) $num"
	fi
done

This simulates 2 bit depth but looks SOOO ugly...

Now the photo...
Top Left:
The CHOPPER with the option of the diode DC offset removing the blue link.

Bottom Left:
The 9V PP3 input to 5.1V supply.

Middle:
4 transistor VFO used for the first part of the DC code.

Top Right:
The VFO test circuit using the two black links connected and transistor input for measurement when links disconnected.

Bottom Right:
3 terminals, top terminal multivibrator output for 3) and for detection.
Middle terminal for the DC input.
Bottom terminal is one of the ground terminals.
To keep this simple it took some working out...

Enjoy. Bazza...
The Alternate DC board for AudioScope.sh.-dc2jpg
# 2  
Old 06-23-2015
Divide by 100?

Code:
R=$((VAL/100))

# 3  
Old 06-23-2015
Hi C'688...

I can't as the real values will eventually be determined by trial and error on the initial build and calibration phases. the V to F relationship is none linear and will range from about 700Hz to 2800Hz; (anywhere in that region depending on the voltage).
As I have pointed out the longhand method works but it is not a lookup table and looks mighty ugly...
Each of the 16 possible values will have its own frequency range as its lookup.
# 4  
Old 06-23-2015
Here is your script with two additional ways to produce the same results. Maybe you'll like one of these alternatives better than your current code...
Code:
#!/bin/bash
range_lows=(100 200 300 400 500)
# lookup
while true
do
	read -p "Number, 100 to 499:- " num
	echo 'Using original if statements:'
	if [ $num -ge 100 ] && [ $num -le 199 ]
	then
		echo "1) $num"
	fi
	if [ $num -ge 200 ] && [ $num -le 299 ]
	then
		echo "2) $num"
	fi
	if [ $num -ge 300 ] && [ $num -le 399 ]
	then
		echo "3) $num"
	fi
	if [ $num -ge 400 ] && [ $num -le 499 ]
	then
		echo "4) $num"
	fi
	printf '\nUsing if-else sequence:\n'
	if [ "$num" -lt 100 ]
	then :
	elif [ "$num" -le 199 ]
	then	echo "1) $num"
	elif [ "$num" -le 299 ]
	then	echo "2) $num"
	elif [ "$num" -le 399 ]
	then	echo "3) $num"
	elif [ "$num" -le 499 ]
	then	echo "4) $num"
	fi
	printf '\nUsing array lookup:\n'
	for((i=0; i < ${#range_lows[@]}; i++))
	do 	[ "$num" -lt ${range_lows[i]} ] && break
	done
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && echo "$i) $num"
done

All of these could be simplified considerably if you know that $num will expand to a number within your known ranges. All of these will fail if $num does not expand to a numeric string.
This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 06-24-2015
Hi Don...

Thanks a lot.

It was the array method I wanted but I couldn't get my version to work.
I will try your version out tonight when I am home from work...

And yes, $num will AWLAYS be an integer number that will default to 0, (zero), before any call.

I will code for errors anyhow...

Again thanks, I will let you know how I get on...

Bazza.

---------- Post updated at 09:13 AM ---------- Previous update was at 07:49 AM ----------

Hi Don...
(Oops, at work.)
You are a star...
DEMO code that works, I couldn't work my own out...
This will be modified to suit my requirements in AudioScope.sh...
Code:
#!/bin/bash
# lookup
range_lows=(100 200 300 400 500)
voltage=(0 0.000 0.125 0.250 0.375 0.500)
while true
do
	read -p "Number, 100 to 499:- " num
	printf '\nUsing array lookup:\n'
	for ((i=0; i < ${#range_lows[@]}; i++))
	do
		[ "$num" -lt ${range_lows[i]} ] && break
	done
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && V="${voltage[$i]}"
	echo "$V Volts DC..."
done

Results just as I require.
Code:
Last login: Wed Jun 24 09:03:07 on ttys000
AMIGA:barrywalker~> cd Desktop/Code/Shell
AMIGA:barrywalker~/Desktop/Code/Shell> ./lookup
Number, 100 to 499:- 0

Using array lookup:
 Volts DC...
Number, 100 to 499:- 99

Using array lookup:
 Volts DC...
Number, 100 to 499:- 100

Using array lookup:
0.000 Volts DC...
Number, 100 to 499:- 199

Using array lookup:
0.000 Volts DC...
Number, 100 to 499:- 200

Using array lookup:
0.125 Volts DC...
Number, 100 to 499:- 299

Using array lookup:
0.125 Volts DC...
Number, 100 to 499:- 400

Using array lookup:
0.375 Volts DC...
Number, 100 to 499:- 499

Using array lookup:
0.375 Volts DC...
Number, 100 to 499:- ^C
AMIGA:barrywalker~/Desktop/Code/Shell> _

# 6  
Old 06-24-2015
Quote:
Originally Posted by wisecracker
Hi Don...
(Oops, at work.)
You are a star...
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
This User Gave Thanks to bakunin For This Post:
# 7  
Old 06-24-2015
Quote:
Originally Posted by wisecracker
Hi Don...

Thanks a lot.

It was the array method I wanted but I couldn't get my version to work.
I will try your version out tonight when I am home from work...

And yes, $num will AWLAYS be an integer number that will default to 0, (zero), before any call.

I will code for errors anyhow...

Again thanks, I will let you know how I get on...

Bazza.

---------- Post updated at 09:13 AM ---------- Previous update was at 07:49 AM ----------

Hi Don...
(Oops, at work.)
You are a star...
DEMO code that works, I couldn't work my own out...
This will be modified to suit my requirements in AudioScope.sh...
Code:
#!/bin/bash
# lookup
range_lows=(100 200 300 400 500)
voltage=(0 0.000 0.125 0.250 0.375 0.500)
while true
do
	read -p "Number, 100 to 499:- " num
	printf '\nUsing array lookup:\n'
	for ((i=0; i < ${#range_lows[@]}; i++))
	do
		[ "$num" -lt ${range_lows[i]} ] && break
	done
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && V="${voltage[$i]}"
	echo "$V Volts DC..."
done

Results just as I require.
Code:
Last login: Wed Jun 24 09:03:07 on ttys000
AMIGA:barrywalker~> cd Desktop/Code/Shell
AMIGA:barrywalker~/Desktop/Code/Shell> ./lookup
Number, 100 to 499:- 0

Using array lookup:
 Volts DC...
Number, 100 to 499:- 99

Using array lookup:
 Volts DC...
Number, 100 to 499:- 100

Using array lookup:
0.000 Volts DC...
Number, 100 to 499:- 199

Using array lookup:
0.000 Volts DC...
Number, 100 to 499:- 200

Using array lookup:
0.125 Volts DC...
Number, 100 to 499:- 299

Using array lookup:
0.125 Volts DC...
Number, 100 to 499:- 400

Using array lookup:
0.375 Volts DC...
Number, 100 to 499:- 499

Using array lookup:
0.375 Volts DC...
Number, 100 to 499:- ^C
AMIGA:barrywalker~/Desktop/Code/Shell> _

You probably either want to make the final echo dependent on having found a value in range, or clear the value of V at the start of processing each time through the loop. I would probably just change the lines:
Code:
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && V="${voltage[$i]}"
	echo "$V Volts DC..."

to:
Code:
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && V="${voltage[$i]}" && \
		echo "$V Volts DC..."

I'm also not sure that this will print what you wanted if you enter a value >= the last entry in the range_lows[] array. (And, I don't know what you want in that case.) Note that in your original code, 100 was the lowest expected value, 499 was the highest expected value, and the code didn't produce any output for out of range values.
This User Gave Thanks to Don Cragun For This Post:
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