author

Peter Balch

305
Inbox View Profile
18Instructables264,773Views269Comments

Tell us about yourself!

Achievements

100+ Comments Earned a bronze medal
10K+ Views Earned a bronze medal
  • DIY Laser People Counter

    > Would you mind if I cite you and add some of your points to my weakpoints list?Sure. Please do.Sorry if I sounded a bit negative but we wasted a lot of time always thinking that the system just needed a couple more tweaks.At the end of each day, after a hundred people had come and gone an empty toilet would be shown as containing three people and therefore "full".So we added extra tests like "if there's been no activity in 10 mins then clear the counter" (which revealed that workers were hiding in the toilet to play on their phones for half an hour) or having an extra PIR sensor in the toilet so the counter never showed zero if there was someone in there.There are better LIDAR sensors but they're much more expensive - $500 vs $5.> I also planned on releasing th…

    see more »

    > Would you mind if I cite you and add some of your points to my weakpoints list?Sure. Please do.Sorry if I sounded a bit negative but we wasted a lot of time always thinking that the system just needed a couple more tweaks.At the end of each day, after a hundred people had come and gone an empty toilet would be shown as containing three people and therefore "full".So we added extra tests like "if there's been no activity in 10 mins then clear the counter" (which revealed that workers were hiding in the toilet to play on their phones for half an hour) or having an extra PIR sensor in the toilet so the counter never showed zero if there was someone in there.There are better LIDAR sensors but they're much more expensive - $500 vs $5.> I also planned on releasing the code extension to use an ultrasonic sensor in a different Instructable, As a people counter? Nope. That was my first thought: an ultrasonic sensor looks along the path to the toilet (or shop door or whatever) and counts as people approach or receed. t didn't work well either. It couldn't see people in a fleece or pullover or heavy overcoat.I suspect that a webcam and AI software on a Pi would be good.> I also wasn't really considering users with malicious intent. Years ago I worked on a big system for giving school kids swipe cards for lunch-money and vending machines. Parents put money onto the school swipecard account. The system prevented, say, diabetic kids buying sweets, bullies couldn't steal your lunch money and there was no stigma attached to kids who got free school meal vouchers. Great. We found that the kids were much more clever than us. One girl was annoyed that she no longer had lunch money as cash which she could spend on cigarettes so she would stand beside a vending machine offering to swipe her card in exchange for cash (at a discount). We spotted strange activity on her account - she would spend all her weeks money on chocolate in one break time.Another group found that if you pushed hard on the glass of a vending machine then the packet of crisps would be delayed. The machine would report a no-vend so we'd refund their account. Then they released the crisps and got them for free.In another school they found that if you swipe the card up and down very fast, sometimes the reader would become confused and debit a different account. Yet others found that if three people shouldered the machine from the left then another two shouldered it from the right they'd get a free vend. Others found that if you switched off the mains to the machine at the right moment it would look like a failed vend and we'd refund them.We were looking forward to the day when someone hacked the comms. We were going to offer them a job.School children are a menace.Peter

    View Instructable »
  • DIY Laser People Counter

    Unfortunately, it's an unreliable way of people-counting. Been there - done that.Firstly, the sensor doesn't like certain clothes and hair styles. A fur-coat, a black fleece, short black hair all confuse it. There was one guy in our office with short black hair and a black T-shirt: it would see him 50% of the time.Secondly, that arrangement of zones often fails. Let's take a typical case: the door is a swing door off a corridor into a toilet. The person walks along the corridor and into the toilet. You want to stop overcrowding in the toilet.As they approach the door they're bringing their hand up to push the door open. It's a matter of chance whether the sensor sees the hand first in the "inner" zone or sees the person first in the "outer" zone. As they leave the door…

    see more »

    Unfortunately, it's an unreliable way of people-counting. Been there - done that.Firstly, the sensor doesn't like certain clothes and hair styles. A fur-coat, a black fleece, short black hair all confuse it. There was one guy in our office with short black hair and a black T-shirt: it would see him 50% of the time.Secondly, that arrangement of zones often fails. Let's take a typical case: the door is a swing door off a corridor into a toilet. The person walks along the corridor and into the toilet. You want to stop overcrowding in the toilet.As they approach the door they're bringing their hand up to push the door open. It's a matter of chance whether the sensor sees the hand first in the "inner" zone or sees the person first in the "outer" zone. As they leave the door to walk along the corridor, they're often turn sharply along the side of the corridor close to the wall (we were taking videos!) so they leave the inner zone and the outer zone at roughly the same time. It's a matter of chance which zone they exit first and which way the the sensor thinks they're going. We tried making the outer zone C-shaped so it encloses the inner zone - it improved things but didn't solve the problem. We thought of putting a barrier forcing people to approach a a right angle but corridor is often a fire escape.The timing is rather slow in the VL53L1X sensor. When you start calculating mSec and sample periods and walking speed you find you have very few samples in which the person is definitely in each zone. Maybe they're moving fast because the _really_ need the toilet.For a product, you have to accommodate people of different heights including children. It's very hard to find a suitable threshold height. Set it too low and a flapping overcoat will confuse it. Too high and it won't see short people.Children are a menace. In a school, you can be pretty sure that the children will work out that by waving their hands they can increase the count and keep other people out of the toilet.(Then there are wide doors and sliding doors and someone pushing a buggy and ....)So my advice is, the VL53L1X is fine for hobby work but don't use it for people counting in the real world. You'll waste a lot of development time and end up with a product that customers are unhappy with.I think it's a wonderful chip and is great for hobby robotics. It should replace the HC-SR04 that we all use.Peter

    View Instructable »
  • ECG Display With Arduino

    Are these errors all to do with using fonts?The error "invalid conversion from 'const byte*' to 'word' in 'DrawInt(f[i], MediumFont, TFT_WHITE);'" might be to do with the 'MediumFont' parameter.I've implemented Fonts in a weird way that could be unique to Arduinos.So as to save RAM space, constant arrays (such as fonts) can be held in ROM. They are declared as e.g.const byte MediumFont[] PROGMEM = { 15, // ymax 4, // descender ...note the PROGMEM construct. You can google for how PROGMEM is implemented and what it means.You have to use special code "pgm_read_byte_near" to access data stored in a PROGMEM array. For instance... void DrawInt(int i, word Font, uint16_t color)calls void DrawChar(uint8_t c, word Font, uint16_t color)which uses the construction (e.g.) b…

    see more »

    Are these errors all to do with using fonts?The error "invalid conversion from 'const byte*' to 'word' in 'DrawInt(f[i], MediumFont, TFT_WHITE);'" might be to do with the 'MediumFont' parameter.I've implemented Fonts in a weird way that could be unique to Arduinos.So as to save RAM space, constant arrays (such as fonts) can be held in ROM. They are declared as e.g.const byte MediumFont[] PROGMEM = { 15, // ymax 4, // descender ...note the PROGMEM construct. You can google for how PROGMEM is implemented and what it means.You have to use special code "pgm_read_byte_near" to access data stored in a PROGMEM array. For instance... void DrawInt(int i, word Font, uint16_t color)calls void DrawChar(uint8_t c, word Font, uint16_t color)which uses the construction (e.g.) b = pgm_read_byte_near(Font);Could it be that the MiniCore boards library has some other way of storing constant arrays in ROM?Peter

    View Instructable »
  • ECG Display With Arduino

    > Did you use electrode gel for your project?Yes - a mixture of gloopy shampoo and salt. No electrode gel was definitely more noisy.> A right-leg drive would improve the noise. Maybe. I don't know. I can see that giving the right and left electrodes a reference voltage that they swing about would be good. It means that common mode noise is reduced and that neither electrode is clipped by 0V or 5V. Why an active "drive" is good, I don't know. I haven't seen an explanation. I think that, for noise from the leads acting an antennae, the impedance of the electrodes will matter. Maybe that's why there's always a resistor in the right-leg drive. Or maybe the resistor is for safety. It would be interesting to compare with and without the resistor.Peter

    View Instructable »
  • ECG Display With Arduino

    Sounds like a good idea. How about building one and making an Instructable?An ESP8266 could probably also write to an SD card.

    Thanks.I looked at your ECG and I don't understand why it's so noisy. There's nothing special about the AD8232 circuit I used but the results were immediately better (which surprised me). The mains hum filter wasn't strictly neccessary.Could it be your 0V "grounding" of the right ankle electrode? The circuits I was looking at online have an active "right leg drive circuit". I think I understand what the right leg drive does; particularly when there's a single supply voltage. Some of you schematics show positive and negative supplies which (I think) means you can use a simple connection to 0V with the right ankle electrode (maybe with a resistor for some sort of impedance matching?). But your other schematics show a single positive supply. I don't see how you can connec…

    see more »

    Thanks.I looked at your ECG and I don't understand why it's so noisy. There's nothing special about the AD8232 circuit I used but the results were immediately better (which surprised me). The mains hum filter wasn't strictly neccessary.Could it be your 0V "grounding" of the right ankle electrode? The circuits I was looking at online have an active "right leg drive circuit". I think I understand what the right leg drive does; particularly when there's a single supply voltage. Some of you schematics show positive and negative supplies which (I think) means you can use a simple connection to 0V with the right ankle electrode (maybe with a resistor for some sort of impedance matching?). But your other schematics show a single positive supply. I don't see how you can connect the ankle to 0V. You're asking the wrist electrodes to be always above 0V - e.g. centred on 2.5V. Mayeb that's why the signal is a bit odd.

    View Instructable »
  • ECG Display With Arduino

    Thanks. I'm going away for a few days and will fix it when I get back.I'm glad it worked well for you.

    An SD card will be tricky but might be possible. I'm going away for a few days so don't have time to reply now. There are discussions below about SD cards. (I think they're here) Did you enable the "fake pulse" in the sketch?

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    I'm sorry I've taken so long to reply. The message never came through to my emails. Instructables usually forwards all messages but not this time.Did you solve the problem?I think you're saying there's a problem with the software - that the calibrateZero constant doesn't work.And you have a problem with the hardware that the voltage it reports is unstable - right?Peter

    View Instructable »
  • ECG Display With Arduino

    Once again, sorry I didn't reply to your previous email - it didn't come through to my email. It's odd, other messages do arrive from Instructables.How did you fix the problem? Was it just switching from Mac to Windows? I'm using IDE Ver 1.8.9 because I use an old XP PC at my electronics workbench.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I've uploaded the Delphi4 source to the Github repository.I believe Delphi4 is available for (unofficial?) download on the web.Let me know whether you manage to compile it.All the best, Peter

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I'm happy to give the source away. However, the program was hacked around a lot as I tried various methods of analysis so it's not neccessarily easy to follow. Plus it's written in Delphi4. If you're a C programmer then it might be hard to translate.If you want to run it on a Raspi then you could try Lazarus. That's a work-alike freeware version of Delphi4. I've used it - it's a nice system. I doubt if it would be plug-and-play for the form design files (*.DFM - I've not tried it). But the Pascal will be identical.If it were me, I'd just start from scratch in your favourite language. It's not a difficult algorithm.Peter

    View Instructable »
  • ECG Display With Arduino

    If all you want to do is store the data then it should be possible to use their example as it stands. But if you want to display it as well, that will be more tricky.I haven't looked at their code in detail to see how they're getting that data rate. It looks like they're collecting the ADC sample in an interrupt then putting the sample in a 512 byte buffer.Presumably it's double buffered so they can write one buffer (a slow operation) while saving new data to the other.How would you also display the data? I wouldn't try to display it in the interrupt handler - interrupt handlers are meant to be quick. So the main loop would need to read the latest data in the current buffer and display it.

    I've got a couple of ESP32s (one with a camera) but I haven't even turned them on yet. I should do it.Why not have a go at a Bluetooth ECG and publish an instructable yourself? To me the question is: what's the advantage? I don't understand what data-logging or transmission to a phone is for. Are people hoping to look back at the heart attack they had yesterday? Would you wear electrodes 24/7?

    View Instructable »
  • ECG Display With Arduino

    Thanks. You're right on both counts. 200 samples at 5mS per sample is one second = 60 bpm.I've also taken out the testADCfast() function which seems to give a problem with some versions of the IDE.I've uploaded a new version of the sketch.

    What will you do with the bluetooth? Will you keep the display? Adding an HC-05 or HC-06 is easy. It's what you do with the data on a phone or PC that's somewhat harder.I've never written an Android app. I tried writing for the iPhone and hated it.

    Sorry for the delay - Instructables only forwarded the message to me today.I suspect the problem is something to do with Arduino IDE versions.Try replacing the call to testADCfast with a call to testADCsimple: testADCsimple();// testADCfast();And remore the testADCfast function declaration.Please let me know if it works.

    View Instructable »
  • ECG Display With Arduino

    Thanks. That's reassuring. I was convinced I would be told how everything I said about the heart is wrong. Mostly that hasn't happened but there is lively debate about how safe is "safe".

    I measured the maximum current from an old AVO Multiminor as 9mA and from an AVO MkIII as 8mA so I suppose they're in the death zone. A modern digital meter gave under 1mA. I also measured the resistance between two ECG electrodes. It was around 150k so a 6V battery connected directly to them would give 40uA. On the other hand, I guess if you have nipple piercings and decided to use some croc clips ...

    View Instructable »
  • Speech Recognition With an Arduino Nano

    If you want to send stuff to my personal email, just search for "peterbalch" online.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    Which of Weka's machine learning algorithms are you using?

    I don't know why the means and SDs don't match the data they're calculated from. I think that the train2raw.txt file contains raw data and the means and SDs have not been calculated - so they're just nonsense. (Except they're not complete nonsense!)In the train2.txt file, which is the processed data, the means and SDs are correct. (The SD is multiplied by 100 to make it easier for the Arduino.)

    View Instructable »
  • ECG Display With Arduino

    I discuss an SD card in Step 13. I haven't tried it with the ECG but I know that SD writes operations can be very long. Interleaving the data sampling and the SD writes would be hard.> here is the url of the system with SD cardThat's a rather brief instructable. He doesn't explain how he continues to collect samples while writing to the SD card. Some SD writes can be over 100mS.Looking at his INO file, he's just using the standard SD.h library which is "blocking" - you can't do anything else while writing.

    Interesting, thanks.The TC58NVG0S3HT seems very cheap - £2 for 142Mbyte. (24hrs is 17M ECG samples.) The write time is 300uS per 2176 byte page - it looks like you have to write a whole page. I can't see whether you can write a page slowly as the ECG samples arrive or whether you'd have to buffer it and write it fast.Have you used FRAM?

    View Instructable »
  • ECG Display With Arduino

    Have you tried the 2.2" display with any other software? Perhaps just try the s/w from one of my other projects. Is the line always there?It looks to me like a fault in the display. It looks like one of the drivers for just one of the display lines is bad.Maybe a faulty connection between the ILI9341 chip and the glass of the display.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I'll be happy to andswer any questions.I think of this instructable as an experimental project. Something for _you_ to try out different ideas.How are you at programming and maths? How would you like to be able to proceed? I was wondering whether converting the filter outputs (on the Arduino) into spreadsheet input (on a PC) would be useful.

    View Instructable »
  • ECG Display With Arduino

    That's a nice clean ECG trace - very little noise.> why the green horizontal line on the 2.2" display?It sounds to me like the display was working but the AD8232 wasn't. Or maybe it wasn't connected properly.That was with a Pro Mini - right? Maybe the AD8232 was connected to the wrong ADC pin. Does the 2.2" display work with your latest circuit?> why does it need resistance on the pads? like how the gel is doing.You should get something even if there's no pad - mostly noise. You shouldn't get just a green horizontal line.You get more noise if the connection to your body has a high resistance. Higher resistance makes the lead act more like an aerial. A pad and gel (or even just salty water) lowers the resistance. Try using a copper coin as a pad.> pls improve this projec…

    see more »

    That's a nice clean ECG trace - very little noise.> why the green horizontal line on the 2.2" display?It sounds to me like the display was working but the AD8232 wasn't. Or maybe it wasn't connected properly.That was with a Pro Mini - right? Maybe the AD8232 was connected to the wrong ADC pin. Does the 2.2" display work with your latest circuit?> why does it need resistance on the pads? like how the gel is doing.You should get something even if there's no pad - mostly noise. You shouldn't get just a green horizontal line.You get more noise if the connection to your body has a high resistance. Higher resistance makes the lead act more like an aerial. A pad and gel (or even just salty water) lowers the resistance. Try using a copper coin as a pad.> pls improve this project more. like more features etc etcWhat features do you think it needs? I just added some more text about experimenting with electro-oculography.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I didn't know that. I used an IBM 360/44 with 128 KB in the early 70s but it never occurred to me to wonder how many MIPS it did. I was happy if I got my punched cards back the same day. I just copied the 15MIPS figure from Wikipedia or somewhere.I don't think any of the workers attempted real time speech recognition. The few papers that discussed the speed of their systems said things like 30 seconds of processing per 1 second of speech.One group connected a telephone handset to a Honeywell DDP-516 to record speech to disk but then managed 22 times slower than real time for analysis. Other groups had special hardware on the input - analogue vocoders and the like. I can't find the IBM360 group's paper or remember what they did.In the 70s I was using the IBM 360 to analyse neurophysiology …

    see more »

    I didn't know that. I used an IBM 360/44 with 128 KB in the early 70s but it never occurred to me to wonder how many MIPS it did. I was happy if I got my punched cards back the same day. I just copied the 15MIPS figure from Wikipedia or somewhere.I don't think any of the workers attempted real time speech recognition. The few papers that discussed the speed of their systems said things like 30 seconds of processing per 1 second of speech.One group connected a telephone handset to a Honeywell DDP-516 to record speech to disk but then managed 22 times slower than real time for analysis. Other groups had special hardware on the input - analogue vocoders and the like. I can't find the IBM360 group's paper or remember what they did.In the 70s I was using the IBM 360 to analyse neurophysiology recordings. I'd record from an oscilloscope onto on paper "film", develop it then digitise it by hand onto to punched tape. One could have done the same with hard copies of spectrograms.It's amazing what they attempted back then but DARPA was willing to pay for it so ...

    View Instructable »
  • ECG Display With Arduino

    Thanks. But, oh dear. Whenever I get more "followers" on instructables, I feel this pressure to publish more stuff. I'm running out of ideas. What would _you_ like?

    View Instructable »
  • ECG Display With Arduino

    Thanks. I say: just build it. The circuit in Step 2 took about 30 minutes from receiving the module to getting a really nice display on a PC. I was amazed at the quality for so little effort.

    View Instructable »
  • Transistor Curve Tracer

    It certainly sounds like there's something horribly wrong with the display. When you get the new one, can you power it from a current-limited supply? Or maybe just put a 100R resistor in the power line. The 662K can only take 6V max input. Is it possible it got connected to the 12V line?It's always annoying when one destroys a module or chip and you've got to wait ages for another one to be delivered. Please let me know how it works out.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    Thanks. I thought of it as a quick project - I am trying to put off completing a much longer one. It was easy because it didn't really require any hardware. And I wanted to learn about digital filters.The next project - the ECG - was also fairly quick but then I took ages trying to learn what an ECG means.

    I don't mind making all my Windows code public but I don't want to have to support it. It's been hacked and modified so much it's not really readable. No-one would enjoy trying to hack it even further.And it's all in Delphi 4. It would be great if you worked on it further. Do you mean write your own Windows code? I think you'd be better starting from scratch in your favourite language. Or do you mean the Arduino code. You already have that.Is there anything you need to know?

    I'm amazed at how well Siri and Alexa and "OK Google" work. Mine is very poor in comparison. As you say, it works best with the person that taught it. But its best is still not good enough for the real world with background noise and a microphone that moves around.

    View Instructable »
  • Transistor Curve Tracer

    > IL9341 display 3v3 or 5V?A good question. The IL9341 chip is 3V3 (actually 2.8 to 3.3V).I've bought a few of the display modules and every one of them has a built-in 3V3 regulator. If you look on the back of the PCB, you'll see it connected to the VCC pin. It's a 662K chip on the ones I have - max 6V input, 200mA. So it can be powered by 5V and you can connect it directly to your 5V Arduino pin. The LED power pin can also be connected directly to the 5V pin. At least, I think that's the case. Other people do that and I've been doing that and nothing's gone wrong. In my schematic for the Curve Tracer, I see I've used an external 3.3V regulator. It was the first time I'd used the IL9341 module and I wasn't sure whether I could power it from 5V. You'll see in my subsequent projects, I j…

    see more »

    > IL9341 display 3v3 or 5V?A good question. The IL9341 chip is 3V3 (actually 2.8 to 3.3V).I've bought a few of the display modules and every one of them has a built-in 3V3 regulator. If you look on the back of the PCB, you'll see it connected to the VCC pin. It's a 662K chip on the ones I have - max 6V input, 200mA. So it can be powered by 5V and you can connect it directly to your 5V Arduino pin. The LED power pin can also be connected directly to the 5V pin. At least, I think that's the case. Other people do that and I've been doing that and nothing's gone wrong. In my schematic for the Curve Tracer, I see I've used an external 3.3V regulator. It was the first time I'd used the IL9341 module and I wasn't sure whether I could power it from 5V. You'll see in my subsequent projects, I just connect VCC and LED to the Arduino's 5V pin.Is your LED backlight still working? You could try fitting another 3V3 regulator. If the 662K chip has burned out, could you bridge it (connect its pins 2 and 3) and test the display by running the board from a 3.3V supply? You can probably get away with running it from the 3V3 pin of the arduino. Its current consumption is less than 10mA. The backlight takes more current and should not be run from the Arduino's 3V3 pin. You can run it from the Arduino's 5V pin. As you say, there are voltage dividers on 3,4,5,6,7 of the display. Pins 13 goes from the display to the Arduino. The Arduino pins are set to input so no current should flow from the Arduino to the display. You'll see I've put 10k resistors in the line so if there's a bug in the Arduino code and the Arduino outputs 5V, the current will be (5-3.3)/10000 = 0.17mA. That should be too small to damage the input pins of the ILI9341.Pin 11 goes from the Arduino to the display. That was me being lazy - I should have put a voltage divider on it. It's got a 10k resistor so, once again, the current is limited to 0.17mA. The ILI9341 has protetcion diodes on its input which will stop that 0.17mA current damaging the chip. The datasheet doesn't say what current the diodes can take - a typical value is 1mA.If look around the web, you'll see other people do voltage-conversion that way. (It's the worst way to do it. The problem is the input capacitance of the pins. Best are FETs or voltage divider chips - they're fast. Next are potential divider resistors - they're slower. And last is a high value resistor - slowest of all.) It works fine with a slowly changing signal like CS but I wouldn't do it with a clock or data signal.Peter

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I personally wouldn't call it machine learning. Yes, it doesn't use a neural network but then you can do machine learning without a neural network - you can learn using a genetic algorithm or even steepest descent. I didn't want to use any of those because they take enormous numbers of samples and I didn't want to spend that long making recordings. I think the techniques that are in vogue today are in vogue because they work better. What I did was the crude sort of thing people did 45 years ago. People didn't think much of neural nets back then during the "AI Winter" because they believed that neural nets could only deal with linearly separable patterns; plus no one knew how to do back-propagation with multi-layer nets.My technique would perhaps be equivalent to a "single-…

    see more »

    I personally wouldn't call it machine learning. Yes, it doesn't use a neural network but then you can do machine learning without a neural network - you can learn using a genetic algorithm or even steepest descent. I didn't want to use any of those because they take enormous numbers of samples and I didn't want to spend that long making recordings. I think the techniques that are in vogue today are in vogue because they work better. What I did was the crude sort of thing people did 45 years ago. People didn't think much of neural nets back then during the "AI Winter" because they believed that neural nets could only deal with linearly separable patterns; plus no one knew how to do back-propagation with multi-layer nets.My technique would perhaps be equivalent to a "single-layer convolutional neural net" or "template matching". I just wanted something that would run on an Arduino and that didn't require too much training.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    Turbo Pascal - yeah! I was a great fan. That's why I now write as much of my code as I can in Delphi. Writing C gives me a pain in the stomach.I suppose a 1D convolution network would work - you slide it over the incoming data streams and see whether the output exceeds a threshold - right? Actually I suppose it's eight 1D CNNs in parallel. I thought of doing it that way but was worried that I ought to scale the input first to normalise it and I couldn't see how to do that with a continuous sliding window. Also, I worried that the the extra continuous maths needed would be too much for the Arduino. So I opted for a "batch" process - trying to collect one whole utterance then analyse it at leisure. It was a fun project but, as you say, its performance is not great in the real worl…

    see more »

    Turbo Pascal - yeah! I was a great fan. That's why I now write as much of my code as I can in Delphi. Writing C gives me a pain in the stomach.I suppose a 1D convolution network would work - you slide it over the incoming data streams and see whether the output exceeds a threshold - right? Actually I suppose it's eight 1D CNNs in parallel. I thought of doing it that way but was worried that I ought to scale the input first to normalise it and I couldn't see how to do that with a continuous sliding window. Also, I worried that the the extra continuous maths needed would be too much for the Arduino. So I opted for a "batch" process - trying to collect one whole utterance then analyse it at leisure. It was a fun project but, as you say, its performance is not great in the real world.Peter

    View Instructable »
  • Peter Balch commented on Peter Balch's instructable MIDI Drum Machine
    MIDI Drum Machine

    With the rotary encoder that I used, the three pins together are for the rotary part. The centre one is 0V and the outer ones are for CW and CCW.The two pins on the other side are for the button-push. Connect them so that one is the button and the other is 0V.I've added an extra photo in stage 4 to show the connections. The rotary encoder you buy might be different.Please do let me know how you get on.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    What sort of accuracy were you getting? The IEEE papers weren't reporting very good results for speech recognition (my Arduino system only works under ideal condition - it's pretty poor in the "real world".)I've attached the contents pages. If Instructables hasn't mangled them they should be good enough for OCR.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    I have posted new versions of speechrecog2.ino and speechLearn.exe which improve the way the two programs communicate.They might also make it easier for you to try wring your own algorithms - see the new Step 11 "Writing your own Algorithm".The changes might take a while to actually appear on Instructables. If you downloaded the code before 17:00 GMT on 13 March 2021 then you should download the new versions.

    View Instructable »
  • Speech Recognition With an Arduino Nano

    Thanks. I enjoy trying to write these kind of algorithms.The Windows program seems to have a couple of bugs and needs a bit of improvement. The digital-filter part is good but the recogniser part doesn't talk to the Arduino properly. I think I've fix it but it's late now so I'll double check it before I upload a new version in the morning.

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    It looks good although I was a little surprised with the words on the box :)Apparently it means _Carp_ eggs with onion salad.

    View Instructable »
  • Peter Balch commented on Peter Balch's instructable MIDI Drum Machine
    MIDI Drum Machine

    I think it did. Try taking it out and see what happens. And try taking out the call to NoteOff() in the NoteOn() function.You could also try my DrumSynth0.exe program (in Step 1).

    > Perhaps the nano just can't quite cope with the data rateThe sounds come entirely from the VS1053.The Nano either does or doesn't send a command - as far as the Nano's concerned either there is or isn't a note. There can be no partial notes.So I reckon it's a problem with the VS1053. If you send a second command to the same voice too soon then maybe the VS1053 gets confused.Commands to sound a note are sent in the NoteOn() function (around line 1089). You can see that I have commented "bug in the chip: sometimes needs percussion twice".A NoteOn command is byte 0x90+n where n is the channel number. (Section 8.9 of the VS1053 data sheet.) In my sketch, the first 47 voices are percussion and the remainder are melodic. In MIDI, percussion is always on channel 9 and the "no…

    see more »

    > Perhaps the nano just can't quite cope with the data rateThe sounds come entirely from the VS1053.The Nano either does or doesn't send a command - as far as the Nano's concerned either there is or isn't a note. There can be no partial notes.So I reckon it's a problem with the VS1053. If you send a second command to the same voice too soon then maybe the VS1053 gets confused.Commands to sound a note are sent in the NoteOn() function (around line 1089). You can see that I have commented "bug in the chip: sometimes needs percussion twice".A NoteOn command is byte 0x90+n where n is the channel number. (Section 8.9 of the VS1053 data sheet.) In my sketch, the first 47 voices are percussion and the remainder are melodic. In MIDI, percussion is always on channel 9 and the "note" says which instrument is "hit"; melodic voices are on other channels (corresponding to the "track" - i.e. the line of the display) and the "note" says which "piano key" is "hit". It's a weird way for MIDI to do it.So you can have a look at what the NoteOn() function is doing.I've tried to get around the bug in the VS1053 by sending the NoteOn command twice for percussion. For melodic notes I explicitly stop the previous note.You could try other solutions. For instance explicitly stop the previous note for percussion as well.Peter

    I began to suspect that the timing of NoteOn command for the handclap was important. If the notes were far apart in time then they were OK but as they got closer they started going wrong.

    View Instructable »
  • Peter Balch commented on Peter Balch's instructable MIDI Drum Machine
    MIDI Drum Machine

    I think you're right about some of the voices not playing every time. Try putting two notes close together on the same track - does the second one always play? Then put the same two notes far apart. Or use the same instrument on two different tracks.I haven't yet worked out what's going on. It's beginning to look like it's a problem in the VS1053. Maybe if a note hasn't finished playing and you start it again it goes wrong. (I always send a Stop command before starting a new note on the same track.)If that's the case, there may be a software fix. The chip has 64 channels but the drum machine only has 8 tracks. Maybe each track could use several channels so successive notes of a track aren't on the same channel.The difficulty with that solution is that the percussion voices are all on chan…

    see more »

    I think you're right about some of the voices not playing every time. Try putting two notes close together on the same track - does the second one always play? Then put the same two notes far apart. Or use the same instrument on two different tracks.I haven't yet worked out what's going on. It's beginning to look like it's a problem in the VS1053. Maybe if a note hasn't finished playing and you start it again it goes wrong. (I always send a Stop command before starting a new note on the same track.)If that's the case, there may be a software fix. The chip has 64 channels but the drum machine only has 8 tracks. Maybe each track could use several channels so successive notes of a track aren't on the same channel.The difficulty with that solution is that the percussion voices are all on channel 9.Is the problem you're seeing with percussion or melodic voices?

    View Instructable »
  • Peter Balch commented on Peter Balch's instructable MIDI Drum Machine
    MIDI Drum Machine

    Which display is it?It can be very frustrating getting a new display working. You've no idea where the problem is: my hardware, the display hardware, getting the SPI to work, a single value is wrong during initialisation.I have bought one of these displayshttps://www.ebay.co.uk/itm/3-5-inch-HDMI-Touch-Screen-LCD-Display-ABS-Case-Box-for-Raspberry-Pi-3B-3B-2B/303669593302?hash=item46b41e44d6:g:vLYAAOSwq9ZfS5SSwhich is meant to work with an Arduino but I haven't tried it yet.There are discussions here:https://forum.arduino.cc/index.php?topic=406097.0https://forum.arduino.cc/index.php?topic=566785.0I would try to get your display to work with _any_ library just to prove that the display hardware and your connections are all good. So I'd download half a dozen libraries and try them all.Adafru…

    see more »

    Which display is it?It can be very frustrating getting a new display working. You've no idea where the problem is: my hardware, the display hardware, getting the SPI to work, a single value is wrong during initialisation.I have bought one of these displayshttps://www.ebay.co.uk/itm/3-5-inch-HDMI-Touch-Screen-LCD-Display-ABS-Case-Box-for-Raspberry-Pi-3B-3B-2B/303669593302?hash=item46b41e44d6:g:vLYAAOSwq9ZfS5SSwhich is meant to work with an Arduino but I haven't tried it yet.There are discussions here:https://forum.arduino.cc/index.php?topic=406097.0https://forum.arduino.cc/index.php?topic=566785.0I would try to get your display to work with _any_ library just to prove that the display hardware and your connections are all good. So I'd download half a dozen libraries and try them all.Adafruit have a libraryhttps://cdn-learn.adafruit.com/downloads/pdf/adafruit-3-5-color-320x480-tft-touchscreen-breakout.pdfI've found that many libraries simply don't work and that the rest are not what I want. They have all sorts of features I don't need and so are huge. Or they try to do clever things to run very fast and so don't share the SPI bus properly with other devices like the VS1053. That's why I wrote my own.

    View Instructable »
  • MIDI Sonar "Theremin"

    KevinI still haven't got around to checking the status register as you suggest - I've had some Actual Paid Work to finish.However, I have noticed that sometimes if a command is sent to play the same note repeatedly, sometimes it isn't played properly. For instance, a "Hand Clap" played every 1/4 sec doesn't always play or sometimes only half plays.I've tried sending a command to stop the previous note before starting a new one. That improves it but it's still not 100% good.Have you noticed the problem? Is there a solution?Peter

    View Instructable »
  • Peter Balch's instructable MIDI Drum Machine's weekly stats:
    • MIDI Drum Machine
      3,431 views
      82 favorites
      4 comments
  • MIDI Sonar "Theremin"

    Interesting. Both the boards I've used were sold as "VS1053". The "theremin" board is soldered in place and the chip is not visible. I just checked the Drum Machine boards and the chip is labelled "VS1053B". Neither of my boards required any special code or hardware changes to enable MIDI.I guess I was lucky.

    View Instructable »
  • Peter Balch commented on Peter Balch's instructable MIDI Drum Machine
    MIDI Drum Machine

    With drum pads or without? Mine's without - I just built some to test it.Please do post an "I Made It" if you do!

    I haven't tried it with an external MIDI input so I don't know about the lag. There don't seem to be any complaints on the web. I didn't notice a lag when using drumpads.The sound quality is good to my ears with a decent analogue powered amp.The VS1053 uses a DAC but I can't work out from the datasheet what the sample rate is when generating MIDI. The DAC is capable of 6.144 Msps when playing MP3.There's some suggestion you should low-pass filter the DAC output. For an audio amp I wouldn't expect that to be a problem but the PAM8403 is a D-class amp and so uses pwm (at 260kHz).It's possible that the frequency of the PAM8403 interferes with the frequency of the VS1053 DAC. There's a disussion herehttp://www.vsdsp-forum.com/phpbb/viewtopic.php?t=2017They suggest an RC filter might help.

    View Instructable »
  • Transistor Curve Tracer

    Maybe.I don't think that Rbe is a useful concept. The base voltage/current curve is so non-linear you can't treat it as a resistor. As I said, you're better considering Vbe so your equation should be I = (Vdac-Vbe)/27k. Vbe depends on Ibe and also on Ice. It's traditional simply to assume that Vbe is 0.7V for silicon transistors (0.3V for germanium) and design your circuit around that.You can measure the base current if you want but why do it? I think it's a mistake to base your circuit design on the exact shape of the Vbe curve - it varies too much between different transistors or with temperature changes or ageing. Design your circuit with plenty of negative feedback to compensate for differences between components or changes over time.My curve tracer shows the approximate shape of the …

    see more »

    Maybe.I don't think that Rbe is a useful concept. The base voltage/current curve is so non-linear you can't treat it as a resistor. As I said, you're better considering Vbe so your equation should be I = (Vdac-Vbe)/27k. Vbe depends on Ibe and also on Ice. It's traditional simply to assume that Vbe is 0.7V for silicon transistors (0.3V for germanium) and design your circuit around that.You can measure the base current if you want but why do it? I think it's a mistake to base your circuit design on the exact shape of the Vbe curve - it varies too much between different transistors or with temperature changes or ageing. Design your circuit with plenty of negative feedback to compensate for differences between components or changes over time.My curve tracer shows the approximate shape of the transistor's response - that's all any curve tracer does. Plug a transistor into different transistor-testors and you'll get very different values for the "gain". The only reason you might worry about the exact gain is to choose a "matched pair" and then you'll simply choose two transistors that give the same reading on the same tester. Even a "matched pair" bought from a reputable manufacturer might differ by 5%.Don't design circuits that rely on exact values of any components - particularly the gain. Use negative feedback.

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    That's an ideal use for it - as a "signal monitor" rather than as an "oscilloscope". Maybe you could have several showing different stages of the mixing or left/right channel.Have you thought about using an analogue input to the Arduino to control the AD9833 frequency? Rather than using an analogue VCO, you could do it digitally in the AD9833. Maybe there are things you can do digitally that are more difficult with analogue. If you google "ad9833" and "vco" or "synthesizer" you get a few hits of people using the ad9833 in synthesisers

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    Nice idea. Is the component tester a LCR-T4 ? The LCR-T4 is great isn't it.You could also add a Saleae logic analyser (or one of its clones but it would be embarrasing to use a clone as they've put so much effort into the Saleae design). And you could add my Transistor Curve Tracer.I've seen other people's workbenches that have a few spare pushbuttons and LEDs for use in circuits you're breadboarding.A voltmeter?

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    What sort of problems? Is there an error message?Have you got an ATMega 168 rather than a 328?

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    You're right, I did nean to say "LM358". I don't think I own an LM258. (I've now changed the text.)This datasheet compares the LM158/LM258/LM358.http://web.mit.edu/6.115/www/document/lm158.pdfThe LM358 is the commercial device and the LM258 is the "industrial" device. It is normally tested to closer tolerances and operates over a bigger temperature range. The LM158 is the military/aerospace part. So, yes, you can use an LM258.Peter

    View Instructable »
  • Transistor Curve Tracer

    The ExecSetupMenu function executes one of the setup menus (for Bipolar or FET) then waits for either the OK button to be pressed or for a device to be inserted. (It also deals with pressing the up/down buttons)It returns false if the OK button is pressed and returns true if a device is inserted.The "if (millis() - time > 1000)" block tests whether a device has been inserted. It does so once every second.I guess you don't have a millis() function in your 18f4620 software. Of course, it doesn't really matter that the test is done exactly once a second. I think I put the timer in there so that the test wasn't done every time round the loop - it slows down the response time of pressing the buttons so should only be done occasionally. Perhaps you could do the TestDeviceKind() te…

    see more »

    The ExecSetupMenu function executes one of the setup menus (for Bipolar or FET) then waits for either the OK button to be pressed or for a device to be inserted. (It also deals with pressing the up/down buttons)It returns false if the OK button is pressed and returns true if a device is inserted.The "if (millis() - time > 1000)" block tests whether a device has been inserted. It does so once every second.I guess you don't have a millis() function in your 18f4620 software. Of course, it doesn't really matter that the test is done exactly once a second. I think I put the timer in there so that the test wasn't done every time round the loop - it slows down the response time of pressing the buttons so should only be done occasionally. Perhaps you could do the TestDeviceKind() test once every 100 or 1000 times the loop is executed.The construction if (millis() - time > 1000) { // do something time = millis();}is used in the Arduino to prevent problems with overflow:https://www.norwegiancreations.com/2018/10/arduino...> For current It has to divide by collector loadTrue. The collector load is 100 ohms. The Arduino uses the "5V" line as Vref for its 10-bit ADC so 5V is equivalent to an ADC value of 1023. (The Arduino compensates for changes in the "5V" line by measuring its internal band-gap voltage reference.) If you do the maths the equation is i = ADC_value * 5 / 1023 / 100So, for instance, a current of 10mA would give an ADC value of 205.The line you refer to is in TestDeviceKind() when it is trying to decide what device is inserted. It compares the current through the collector load using if (i > 50) {}A current of 2.5mA gives i = 51. So the program is testing whether the current through the device is greater than 2.5mA.Peter

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    So no pressure then? I'm getting embarrassed that I haven't published anything for 8 months. I've got a couple of projects in the works but I'm waiting for stuff from China. Soon - honest.

    View Instructable »
  • Oscilloscope in a Matchbox - Arduino

    Looks good. I've always used stripboard rather than perfboard. I'm impressed by your handiwork and have ordered perfboard to use in whatever is the next project.

    View Instructable »