Search This Blog

Saturday, July 28, 2018

Sonar for the visually impaired - bring up

Projects / Project Swiftlet  "Hello Hell Desk?" Original post date: 07/27/2015

I have been putting off doing this next part - working on porting ChibiOS. I guess that's one of the things on my to do list before the PCB comes back. Not into the whole makefile command line nor linux nor run weird environment over on Windows nor making my tool chain.

There is a new stable release of ChibiOS 3.0.0 here on July 12th which was 9 days ago. I guess that's the one I should be porting over.

The C compiler include path is as follows:


I am trying to play with RVCT. Right off the bat, the supplied "RVCT" assembly file don't work directly as they added a whole pile of C preprocessor junk to what should have been a simple assembly file.



  1. First thing to do is to right click the Project. In the Asm tab, add the "--cpreproc" option under Misc Control. This runs the assembly file through the C Processor, so now those proeprocessor command would work.
  2. Add in the include path: ".\myprojects;.\os\rt\ports\ARMCMx;.\os\rt\include" 
  3. Note: .\myproject is where I put the chconf.h.

At this point, I get the errors down to a manageable 2. So I guess it is not too bad so far. Next thing to do is to play with the starup code where the errors come from.

Right now I am just going to use the KL25 Freedom board files as initial port as it is the little brother of KL26 on the Teensy LC (minus the I2S.)


"The missing symbol is the result of a change in the keil compiler, $ become an escape character so it should be replaced by $$ in the linker settings. I will check both 2.6 and 3.0 projects."

Except we need "$$$$" where we had "$$". Fixing that, the OS compiles error free.

Bricked my Teensy LC after I erased the FLASH and try to program in a test image. What really happened is that ChibiOS code have poor RVCT and Freescale support. The supposedly stable code has not been verified!


Guess what guys? RVCT not only did not reserve a space at $400 for it, but nukes that .cfmconfig block away. If you now program this in, there is a very high chance that the chip has been irreversibly bricked. i.e. The bulk erase function is disabled too.

I modified the Freescale start up assembly code and it works as expected:


So lessons of the day:

  • Always check the map file!
  • Don't try to try to pretend that stuff is portable and even try to code that in C.
  • GCC section might not be portable across compiler.


Code name "Swiftlet" - PCB Fab

Projects / Project Swiftlet  Original post date: 07/24/2015

Going to take a little break from codenaming PCB after Comic book characters as they don't quite have the fit for this project. Code name for this PCB is "Swiftlet". It is an agile little bird that use simple but effective echolocation for navigating caves in total darkness.

Here is the the latest PCB in a panel. I am going to go over that and might order the PCB later tonight if everything looks right.



Files sent to PCB Proto place. Time for this little bird to fly. Initial proto PCB build are now on my Github.

The PCB vendor sent me this picture this morning. That looks like my PCB. The main PCB is slightly bigger than a 2 AA battery case. The silkscreen alignment on the front actually looks right too. That speaker grill came out but looks different. I'll have to measure it at some point.

It is going to be taking the long way home on the postal system. They are using paypal postal labels and I have been told that tracking won't be available for 3-4 days. China Post seems to be slower since earlier this year.

Paypal package:

It is going to take a slow trip up north to Beijing where the International mail get sent out. My other project is taking the same trip a couple of days earlier.



Last entry: 5th Aug: Flight departure from Bejing. It would take about a day to arrive in Canada.
It missed the flight on 3rd Aug by a few hours and got on flight on 5th. It would seem like flights are every other day.

Still no status update on the arrival. Hope it didn't run into Super Typhoon Soudelor. Meanwhile the PCB of my other project that left China is still sitting at the Canada Custom for the 3rd day.


Right now the postal delay really ties my hand. I was hoping to get the PCB assembled and have at least a week working on the firmware. Given the slow Canada Custom, I would be luck at all to get the bare board before end of next week. Canada Post isn't know to be speedy, so it'll take them at least 2 days (and likely more) to just move a package from the west coast to the east.

This is crazy. My package went all the way up to Bejing, then took another trip back down south to Hong Kong (which is 45 minutes next door to the PCB place), then supposedly arrived in Vancouver the the 6th. It basically wasted 1 week for a big tour in China. Canada Post still have no record that they have received it.

Hard to tell what's going on here as now there is no longer tracking. There is a new date on the status of my other project. that was sent out 2 days earlier I can only assume that the first package might have passed through the Customs on the 17th. Or could this be the IT upgrade this Friday?

Editorial note: This is exactly point when Canada Post decided not to share it internal tracking info.  For a couple of months after this, I could still get some tracking info using a bug in their system.  This is first time I have seen downgrade in IT system.


I got a package notification card for my PCB that was sent 2 days earlier in the mail today, so I guess it is a matter of next week if/when this package would arrive assuming that for whatever reason Canada Post decided to shut off the tracking. Since there are no info all, there are chances that custom could take a longer time or that it was lost for some reasons.

Looks like the slow customs finally let the package through and now the lazy delivery person would rather hand filled a notice, go into the mailroom to put for the card than to try to delivery the actual registered mail package. Looks like I am going to do some soldering tonight when they drop off the undelivered packages to the local outlet across the street. I am going to pull my trick of getting information from supposedly untracked packages.

Reminds me of the TV show "True North" about a Canadian mountie in the US.  One ep. they had someone at the Canadian embassy with perfect French saying she doesn't understand French.


Sonar for the visually impaired - component selection

Projects / Project Swiftlet  "Let's go shopping II" Original post date: 07/20/2015

Got my BOM sorted out with the help of BOM-EX ULP in Eagle (Home, Eagle CAD site). I have looked up the digi-key part# and did some clean up.

What I have seen is that 0402 parts are cheaper than the 0603. Most of the parts on this board uses 0402 for size. There are a couple of parts such as the MOSFET array that is pushing the PCB geometry. I had to alter the recommended footprint to meet the minimum spacing.

So going to put together a digikey order early next week, try a few things and then finalize the PCB.

need to determine the exact spacing for the battery holder as they don't come with recommended layout data.
need to finalize the choice of speakers. As for mounting, probably have to make something up and use connector+wire for this iteration. Speaker acoustic and case designs will have to wait until most of the hardware/firmware design are working.
still have to do a small breakout board for the left side to connect the sensors, speaker and haptic motor.
I have yet to figure out the connectors, speakers, ribbon cable and half a dozen smaller things that I need to order extra for trying things out.

I have placed the digikey order for parts.

  • Got settled on Hirose DF11 2mm connectors. These are IDC for AWG#26 loose wires. Hopefully this gives a bit more freedom on the cord connecting the two sides. Their pin numbering scheme is a mirror image of the usual ones!


DF11 2mm connector - IDC for AWG#26 loose wires or ribbon cable
  • picked JST 1mm IDC connector for speakers
  • C&K slider switch I was hoping to use isn't in stock, but thankfully there is is a more expensive Japanese CL-SB-23C-11 which has exact same dimension.
  • Trying out Knowles Nautilus Speakers. It has an integrated side-port exit. Also getting their regular speaker for comparison.
  • I saw some speakers on Aliexpress, but as usual the quality on their picture doesn't impress me much and I am out of time for trying stuff on slow boat right now. The interesting part is the speaker parts with their enclosures. That's the hardest thing to get right in a prototype if you don't have a 3D printer.

Forgot all about the Thermometer + EEPROM on the sensor PCB when I was working on the BOM. I guess I'll have to make do with the more expensive and less integrate parts I have on hand.

Ordered wrong resistor size: 0603. Changed design to not use the value. Made some bad choices for inductors. I have to redo the footprint and push things aside for the larger inductors. Going to try out cheap Chinese knock off inductors this time and may be I have better luck? If that fails too else fails, then I'll pay the $8 and order the legit part from digikey.
The contacts in the battery holder are pretty stiff. So it looks like the spacing I had is a bit too short. Going have to drill a few holes on a scrap PCB and try it out.

The JST connector I picked for the speaker is the same the one in my broken camera! So I guess I can try that speak out at some point.

Without an enclosure, that Nautilus speaker works a lot better than the Aliexpress "iphone" speakers. Even their $1.5 speaker was a few times louder. The side port exits works really well and when you point it towards the outer ear. With a properly designed enclosure, it would only get better.

Still need to redo the layout to accommodate the much larger inductor. Thankfully, the spacing of the battery holder has increased.

Looks like I'll need to limit the power usage for AA/NiMH battery mode operation. When running from a Li battery, the power available is much higher as I am using a different buck converter.

I have wired up the boost circuit for testing.

MCP1640 Boost converter test circuit
It seems like the inductor would work fine as long as I keep the current below 100mA and input voltage above 1.1V. A tiny bit over, it saturates, the inductor heats up, efficiency drops and the output loses regulation. I have also tried it with an inductor with a higher saturation current rating. This time the MCP1640 heats up, so either way there is only so much power can be delivered in this mode.

It might not be a huge issue as we are drawing above 400mA from the AA battery. From the battery life point of view, it should be avoided in the first place. The only thing that draws that amount of power is the audio circuit and it would seem that the higher efficiency of new speaker might help to reduce that.

Note: At outdoor because of the ambient noise level, the amount of power might need to be increased by a few times.

I bought some JST 1mm SR series IDC connectors for the speaker connection. They are tiny polarized and do not take much vertical spacing. The beauty is that these connectors requires no $200 crimping tool to make. In my case, I just use my finger nail to push the wires into the slots. I used the dull size of the box cutter blade to push it in a bit more for good measure. The contact blades on both sides cuts through the insulations and make air tight contact with the stranded wires inside. The plastic grippers at the end of the connector grip onto the outside of the wires. It is a good system. I am lucky that the AWG28 wires (from scrap piece of round SCSI cables) would fit into the connector that was designed for AWG30. My only complain is that there is no where to grab onto if you want to remove the connector.

JST 1mm IDC connectors


Sonar for the visually impaired - UX ideas

Projects / Project Swiftlet  Original post date:07/09/2015 “Show Us Your Human Interface”

This was one of the things on my mind, but I didn't write it down in a specific section. I guess the “Show Us Your Human Interface; Win Laser Cutting Time” is a good incentive for that.

Since this device is designed to operated with a visually impaired person, the user interface is a bit different than most. The device is equipped with dual haptic motors and dual speakers that can be used to communicate with the user for environmental and navigational information.

Informational messages
The dual haptic motors can be used to give directional information such as left or right based on which of the motor is energized. The frequency of the pulses can be used as analog feedback such as closing of distances.

In the sonar mode, the raw ultrasonic signal is slowed down by a factor of 20X, this gives the user access to the analog echo signals and motion detection via dopper effects. (more details here)

The following picture shows the raw echo signals that can detect objects/boundary at multiple distances - (large blip) door threshold, (small blip) door and (large blip) far end wall. (project log here) These type of information is not available if you use the ultrasonic range finder module as is and hook up the 4 pin interface to a microcontroller. The module would only return the first echo and ignore everything else.


Research paper has shown that a person can be trained to process these signals to get an overall 

"Results: Naive subjects were able to make laterality and distance judgments, suggesting that the echoes provide innately useful information without prior training. Naive subjects were generally unable to make elevation judgments from recorded echoes. However, trained subjects demonstrated an ability to judge elevation as well."

The SPI FLASH memory can hold voice samples for words for constructing short messages 

numeric measurements such as distances, height/depth, battery voltage, temperature
direction: N/E/S/W, left/right, bearing
warning message: stop, proximity alert

Interactive User Menu

The accelerometer used in this device was designed for a mobile device and can sense single/double tab (pulse of acceleration) to bring up user interface. The same function can be used in this device.


  • A single tap can be used to bring up frequent used function such as a sonar ping.
  • A double tap can be used for is to bring up a more complex voice prompted menu, where by the user can navigate by simple head motion.
  • Nodding/shaking head can be interpret as Yes/No answer to a question. These can be detected by the 3-axis accelerometer.
  • The amount of head turning or nod can be used as analog value for adjusting options.
The orientation of the device such as facing down or lack of motions can be used to tell the device to go into sleep mode.

Debugging

For firmware debugging, I intend to use a LCD graphic display with the Alien movie "Tracker" style user interface which is exactly the type of display to show echos. A polar plot + a few line of text can show the echo and orientation information. I wonder if this can be also be sold as a toy/novelty item.


Ultrasonic module reverse engineering

Projects / Project Swiftlet  "Ultrasonic Module - Let's get physical" Original post date: 06/27/2015

This is a physical teardown of the HC-SR04 Ultrasonic Range Finder modules sold from China. This part is the old fashion kind. This is just for completeness.

Observations:
  • No copyright, no designers name or anything.
  • Some board uses the old LM324 and some uses the SGM324 (CMOS RRIO).
  • One of the boards with the SGM324 has the opamp pin 5 grounded in the PCB layout, but everything else looks identical. After modding it to match the rest of the boards, it works better.
  • Rest of the parts have part# removed.
  • U3 seems different
  • Not much change except for a few cost reduction and part designation renumbering
  • Judging from what's been selling on the ebay/Chinese sites, the most likely part# that is on the module is: TCT40-16R/T-2 from Sunway / Shenghui
Components is placed on a printout of the scan

  1. Take a picture, print it out and strip parts off the PCB one at a time. The parts are taped down to keep track of what goes where on the board. Make sure that it is in a geographical stable location away from wind, pets etc. :) Some people like to use icecube trays for these type of work.
  2. Scan the board in a flat bed scanner
  3. Import the scan into an image manipulation package
  4. Scan pan rotate zoom enhance!

Bottom scan:


Select the silkscreen areas and re-level to reveal what's under.


Readjust the tint to match the rest of the board. (by eyeball)


(I am skipping clean and repair image as it will take me an hour or so)
Flip the scan horizontally for merging (click for high res. image)


Top Scan: minor de-noise applied (click for full image)

I'll let someone merge the image. The board is simple enough for me to skip that step.

5. Measure component values, sketch out the schematic


I saw a variant of R2 = 56K (563) in some of my modules. All it means is that the gain will be lower.

Original schematic from Emil's Projects: "Making a better HC-SR04 Echo Locator". Updated by me to the most recent PCB version.

Annotated schematic for the differences - Click to see full resolution