Designing a custom Lightsaber PCB - code writing time.... - Page 1
Forum section: electronics / projects

author: Canobi
author_rank: Regular Contributor
timestamp: April 22, 2015, 08:09:16 pm
content: Hi guysI've been making custom/replica props in my spare time for a few years now and one I keep revisiting as my skills develope is the lightsaber.This time I'm upping the ante and making my own custom PCBs for my projects. I built a PCB fabrication lab (most of it anyway) so I didn't have to deal with loose running wires and the constant repairs that go with fitting that kind of setup.I've already made a good start on a new PCB layout, and I'm just extending it as I add additional functions (board width has to remain within 20mm, I can extend it to 5 or 6 inches if necessary).With a bit of luck the full board will include all of the following:• charge management• charge status indication• soft latching switch• embedded audio• sound amplificationCharge management/indication is an obvious one for me as it saves having to remove the battery. I'm using an MCP73833 and GTR CR123A combo. The battery has a PCB mount holder on the blank side, the SMD components are on the other (still doing single sided but I'll get there).The soft latching switch is both timely and a godsend.It's timely as I happen to be learning about transistors n fets on an EE course I'm on and thought it would be a bit of handy practical to include it in the circuit.I found out about latching circuits during some side research. The trail eventually led me to the design I'm going to use provided by this site:http://www.edn.com/design/power-management/4427218/Latching-power-switch-uses-momentary-pushbuttonIt's a godsend because fitting bulky panel mount latching pushbuttons to 10" x 30mm tubing is just the pits (if you like puzzles, give it a try, I dare you. Your choice is: try and fit a nut on a button thats mounted half way down the shaft langth, or, tap threads and risk twisting the wires off screwing the button in).This finally brings me to my reason for posting (soz about the waffling). I need some suggestions for integrating audio.Anyone know of a decent multi addressable playback IC that isn't discontinued, unsupported, badly documented, overly expensive, or available but only come in batches of a million and in obligatory repeating orders.I bought a Nuvoton ISD2540 and a 1700 way back but it looks like both fall into at least two of the catagories above and without the software/hardware/accurate data support for them, I've been reluctant to try them out (I know my limits, I'll just go and let all the magic smoke out lol) so I've been looking for current/up to date alternatives but have been met with little success.Any suggestions for solving this one would be most welcome.For the amp I'm thinking a 1w digital, or 2w and a stick a boost buck in the mix, though finding a way to actually store and play sound has been taking up most of my left over free time (when I get any that is).

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 22, 2015, 08:25:36 pm
content: I had the same problem and endet up buying the bigger version of this:http://www.mdfly.com/products/tf-microsd-card-mp3-player-module.htmlVery easy to use but it has a slight lag between selecting the file to be played and the output, maybe 0.1 seconds or there about.Never measured it.No need for datasheets, you put the file on the SD card and just tell the module over the UART interface wich file should be played.Worked great in my laser rifleEdit: The bigger board uses a LM317 as voltage regulator, you might want to desolder it and short it if you allready have a voltage regulator.In the small form factor you will have problems getting a decent sound level, decent small speakers are somewhat expensive.One of the small "5V Class-D USB audio amps" sold on ebay by the bucket should do nicely.

author: Canobi
author_rank: Regular Contributor
timestamp: April 22, 2015, 09:56:01 pm
content: Thanks for the link PeterMFTurns out they sell the chip on its own which is just what I'm looking for, I owe you onehttp://www.mdfly.com/products/vs1003b-audio-decoder.htmlI'm off to find the data sheet and do me some reading.

author: rexxar
author_rank: Frequent Contributor
timestamp: April 23, 2015, 04:37:42 am
content: Interesting, I'm working on a lightsaber PCB as well. I just sold my first board today, in fact! It's a RGBW LED controller with a PC program to chose colors and such. Integrated battery charging and some other goodies! And the board comes in at just 18x50mm.If you didn't know, there are several people online selling sound fonts, big packages of pre-recorded lightsaber sound effects.I've not started work on my sound module yet, but I'm planning to include an accelerometer, to play whatever effect the user wants on hit, swing, etc. You may want to consider that yourself.

author: Canobi
author_rank: Regular Contributor
timestamp: April 23, 2015, 06:25:57 pm
content: Quote from: rexxar on April 23, 2015, 04:37:42 amFor me, the saber PCB is my training ground for a much bigger and more serious replica prop project I've slowly been working on for about 3yrs. The electronics is the only part left that is holding it back so I chose the saber board as it's almost a simplified version of what I need and thought it was a good starting point.I have some fonts ready to go, but as I've been into sound design and music production for most of my life, I may have a crack at making a custom set.I have a MR Vader soundboard I got in a PIF on another forum, that uses a spring motion/impact sensor switch, but it's quite literally a bit hit n miss when it comes to sound vs action. The accelerometer would be much more accurate in interpreting movement. The only downside for me is it needs an MCU to be useful. Programming is where my limit ends for now, I'm numerically dyslexic (the reason I haven't got as far with electronics as I'd like) but it's not completely crippling, it just takes longer for stuff to make sense and sink in (like transistors did yesterday, proper eureka moment).

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 23, 2015, 06:58:58 pm
content: Quote from: Canobi on April 23, 2015, 06:25:57 pmBuilding props if fun, wanna see were i used the MP3 module i bought?Hand crafted doom-beam-exciter out of glass and copper with 64 seperately wired leds, 64 PWM drivers and a lot of enamel wire:Sadly i ran into a rather big problem wich i had not the nerve to tackle, so my death ray is sitting on the shelf as do my dreams for world domination...

author: Canobi
author_rank: Regular Contributor
timestamp: April 23, 2015, 08:38:25 pm
content: Do tell... It's lookin boss, would be a shame to shelve it.And since you shared, here's another WIP of mine:And I may have found just what I was looking for on RS:http://uk.rs-online.com/web/p/speech-recorder-ics/7003504/

author: Richard Crowley
author_rank: Super Contributor
timestamp: April 23, 2015, 10:19:26 pm
content: Unless you are planning for long-term mass-production, the VLSI VS1000D-L looks like exactly what you seek.Data Sheet:http://www.tme.eu/en/Document/501955d8469c3ed330c9828447a412f0/vs1000.pdfExample product from Adafruit:https://learn.adafruit.com/adafruit-audio-fx-sound-board?view=allExample product from Sparkfun:https://www.sparkfun.com/products/retired/8849Currently 50% off at Sparkfun:https://www.sparkfun.com/products/8300Available by the each here:http://www.tme.eu/en/details/vs1000d-l/drivers-integrated-circuits/vlsi/The biggest problem I see is what you are going to use for speaker(s). You need something with some decent cone area if you want to reproduce any moderately low frequencies. Maybe some speakers in a belt-pack/holster or something?

author: Canobi
author_rank: Regular Contributor
timestamp: April 24, 2015, 04:32:23 pm
content: Neat ic, though I couldn't help looking at the VS1103 as it can loop seamlessly, and play multiple channels at the same time.This is key as mixing/layering of two or three samples needs to be implimented on order for the saber to sound right.

author: Zero999
author_rank: Super Contributor
timestamp: April 24, 2015, 08:00:48 pm
content: Quote from: Richard Crowley on April 23, 2015, 10:19:26 pmPerhaps there could be a small speaker on the lightsabre and an FM transmitter to send it wirelessly to a boombox for the bass. Of course you'd need to make sure the RF power output is low, otherwise you'll be in trouble.

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 24, 2015, 08:21:29 pm
content: Quote from: Hero999 on April 24, 2015, 08:00:48 pmI checked just now to be shure if i remembered it correctly.The lightsaber has not that much low end, if you get down to 200Hz it still sounds nice enough.200Hz you may be able to do with decent small speaker but it will be a bit of a challenge

author: Canobi
author_rank: Regular Contributor
timestamp: April 25, 2015, 08:03:45 pm
content: I was just going to go with a 1-2w 28mm mid range cone in the pommel. As Peter states, no bottom end to woody about (unless you were on about his ray gun).

author: Canobi
author_rank: Regular Contributor
timestamp: April 26, 2015, 11:25:54 am
content: Well, been go ogling around again and found this company offering various speech ICs, one such is a duel channel playback ic. Will be finding out how hard they are to purchase as a hobbiest.http://www.lapis-semi.com/en/semicon/speech/ml2282x.htm

author: Canobi
author_rank: Regular Contributor
timestamp: April 28, 2015, 10:33:55 am
content: Not easy it turns out. I only found one of their devices and that was through RS, though I think it'll only play one sound at a time, and I couldn't find it on the Lapis website so probably another discontinued product:http://uk.rs-online.com/web/c/semiconductors/audio-processor-circuits/speech-recorder-ics/?searchTerm=speech+playback+icDug out my ISD chips and found one to be an ISD2360 in SOP 16 package, not a 2540 DIP I originally thought it was. After looking up the data sheet I found the MCU schematic was pretty basic so I'm going to give MCU control a go. Shouldn't need a heavy duty one, something like the arduino pro mini chip would be more than sufficient by my guess.Anyone know what it's called?Here's the ISD2360 schematic for host control (I've included the chip pin out and diagram as the schematic is based on the qfp package)

author: senso
author_rank: Frequent Contributor
timestamp: April 28, 2015, 10:39:10 am
content: Why not just use a 8 pin 64Mb flash with all the sounds in there, and use a small micro-controller to generate the sound directly from PCM audio that is stored in said flash?The micro can be anything that has an 8 bit timer, with 16 bit timer you get more audio resolution, the solution can be very small and compact.The amplifier can be as simple as a transistor, or a QFN class D amp from TI.

author: Canobi
author_rank: Regular Contributor
timestamp: April 28, 2015, 12:06:40 pm
content: Quote from: senso on April 28, 2015, 10:39:10 amThanks senso, I'll look into that

author: Canobi
author_rank: Regular Contributor
timestamp: April 29, 2015, 12:05:37 am
content: This is new territory for me so have no idea if my choices are any good, but so far I've been looking at these as they're nice and small:64Mb mem =http://uk.rs-online.com/web/p/flash-memory-chips/7824660/Amp ic =http://uk.rs-online.com/web/p/audio-amplifier-ics/7098726/Still looking for an appropriate MCU....

author: rexxar
author_rank: Frequent Contributor
timestamp: April 29, 2015, 05:36:56 am
content: Quote from: Canobi on April 28, 2015, 10:33:55 amAtmel ATmega328 (or 328p). It's slightly more expensive, but if you want to use the Arduino IDE with it, I'd recommend using the 328p version, else you need to screw with some settings to get code to compile. They come with the internal oscillator preset, so you don't need to use an external crystal so long as you're careful with your fuse settings.I'd recommend using an SD card for storing your sound files, actually. You can still access it with your microcontroller using SPI, but it's easier to load files. Rather than dick around trying to send 64Mb over a serial connection, you can just stick it in your PC. Either way works, though, it's just down to cost vs. convenience. In my case, I'll have users wanting to change and customize the sounds, so I figure an SD card is the easiest option.

author: Canobi
author_rank: Regular Contributor
timestamp: April 29, 2015, 08:11:48 am
content: Quote from: rexxar on April 29, 2015, 05:36:56 amThanks rexxarSD card sounds like a simple solution, would it work with micro SD?Micro isn't really essential as I think the standard SD card reader will just about fit on the PCB, just wanting to keep with the "small" componants theme for aesthetics.

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 29, 2015, 12:35:20 pm
content: Quote from: Canobi on April 29, 2015, 08:11:48 amYes, they are identical, except for the size.A ATMega328P could be enough for your project, if you run it at 3.3V and 8Mhz it makes the whole thing easier.But i do not know about the speed requirement for your audio stuffGreetings,Peter

author: Canobi
author_rank: Regular Contributor
timestamp: April 29, 2015, 09:44:22 pm
content: Quote from: PeterFW on April 29, 2015, 12:35:20 pm3.3v sounds like a good ballpark voltage, my plan is to use a 3.7v LiPo so trying to choose componants that operate in that range anyway. Simple is good too so 8Mhz will do for a first shot as wellAs long as the audio doesn't sound like a speak n spell trying to make lightsaber noises I'm all good. I can convert audio to just about any format or resolution/speed required.

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 29, 2015, 10:12:58 pm
content: Quote from: Canobi on April 29, 2015, 09:44:22 pmMaybe something like this could be enough for you:http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudioThere are quite a few other project describing how to play WAV files straight from the SD card using a Atmel µC.The only hardware you need is the processor, the sd-card and a few passive components.From what i have read, the sound quality should be enough for a light saber.Edit: You could even roll your own "player" using two chips, one for the audio only and one for the other stuff.A bit cheaper then using the next bigger chip but twice the power requirement.About 15mA for each MCU and between 1mA to 50mA (idle) and 100mA to 300mA (active) for the SD card.

author: Canobi
author_rank: Regular Contributor
timestamp: April 29, 2015, 11:41:59 pm
content: So looking at my saber samples, there's only about 20 seconds worth altogether.I didn't know SD cards took so much current, might be an issue as the LED uses about 600mA on its own, my guess would be that flash mem might be the best option in this case.The number of samples could actually be reduced if an accelerometer was included. Again, lacking full info but, if the data from the accelerometer were somehow translated to the playback pitch of the looping blade hum sample, it would behave very very closely to the lightsabers seen on screen.About five or six of the short sounds I have are sweeps, my guess is they were intended as interrupts that would be played instead of the hum when meduim/meduim heavy movement was detected by the sensor (spring impact sensor most likely).

author: PeterFW
author_rank: Frequent Contributor
timestamp: April 29, 2015, 11:56:34 pm
content: Quote from: Canobi on April 29, 2015, 11:41:59 pmIt depends on the card, if you use a name brand card the datasheet will tell you the precise numbers. You can get cards that are designed for low power use.The 300mA is a very unlikely worst case current of some bad cards.Usually they are under and around 100mA when reading/writing.Have a look at this, looks like SPI flash with a processor and external DAC:http://www.artekit.eu/diy-lightsaber-audio-board/

author: Canobi
author_rank: Regular Contributor
timestamp: April 30, 2015, 12:42:34 am
content: Quote from: PeterFW on April 29, 2015, 11:56:34 pmThat's cool, not sure how one would get it in a hilt though, it's about an inch too wide. There seemed to be a bit of a delay between sound playing and movement, is that down to coding?I'm just trying work out if it's possible to get more out of the data from the accelerometer since it appears to me that its down to creative coding and MCU capabilities for achieving optimal functionality. They seemed to only use it for activating the whoosh sound and had a seperate button for the clash sound in that setup, I thought it would be possible to get more out of it unless I'm off the mark with accelerometers that is.Sound quality was rather good though, and 4w is louder than most sabers produce that I know of. Most go for 2w or less due to speaker size restrictions (27-28mm diameter are the "go for" sizes for a lot of saber smiths as they fit inside the hilt blanks perfectly so not a lot of extra work is needed to include them).

author: rexxar
author_rank: Frequent Contributor
timestamp: April 30, 2015, 12:49:03 am
content: Quote from: PeterFW on April 29, 2015, 10:12:58 pmThat's not a bad idea, actually. I can't find an off the shelf chip that does everything I want, so I think I'll just use another 328p.

author: Canobi
author_rank: Regular Contributor
timestamp: April 30, 2015, 07:24:54 am
content: Quote from: rexxar on April 30, 2015, 12:49:03 amThat's the trouble when your just starting out, it's difficult to see all the possibilities when you don't know the limitations.Good suggestion though, may try that myself.

author: Canobi
author_rank: Regular Contributor
timestamp: April 30, 2015, 09:31:02 am
content: Digging around I came across this little codec, might be worth trying out as it's about the same price as a 328P:http://uk.rs-online.com/web/p/audio-encoder-decoder-ics/8124066/

author: Canobi
author_rank: Regular Contributor
timestamp: May 03, 2015, 05:11:53 pm
content: Hi guysI'm having a little trouble working out what pins to use for a couple functions on the 328p. I've opted to use as flash memory as it takes up less real estate than a micro sd card, less current and oer ates at a max of 3.6v (N25Q064/N25Q064a)So I get five of the pins: data in/out, CLK and Vcc/Vss pins used for SPI, but there's a couple I'm not sure on: chip select (pin 1), W#/Vpp/DQ2 (pin 3), HOLD#/DQ3 (pin 7), will I need to connect these pins, if so to which pins on the 328p?Also not sure which one to use as an inturrupt switch for activating sounds.To keep things simple for me I've opted out of using an accelerometer for now. My hope is to either use a spring vibration/impact sensor switch as an interupt switch with two level activation (sweep sounds for small/meduim vibrations, clash sounds for impacts, amd for later experimenting if I can find some basic example code to play with, I'd also like to try and use a pressure sensor strip at the Base of the blade.If my understanding of the sensor and capabilities of the MCU is right, then it should be possible to assign predetermined pressure and time thresholds to activate different sound sets.I'm assuming I use the two PWM pins for a speaker right?@rexxar, I'd be interested to know how the duel chip setup works out.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 04, 2015, 01:00:08 am
content: Well, I've got finals this week, so I've not had time to do anything, I'll let you know what I come up with once I have some timeAs for pins, I can definitely help you there. For SPI, chip select on your slave device can go to any digital IO pin on the uC. On the SPI EEPROM I use, HOLD is tied to Vcc, and W is left floating, so check your datasheet, it's probably similar. As for your motion sensor, PD 2 and 3 (pins 32 and 1) are interrupts 0 and 1, I'd use these for changing the current sound effect. Since it's got two levels of activation, you can tie an interrupt to each and have the uC decide what to do with that.Quote from: Canobi on May 03, 2015, 05:11:53 pmThat depends on what sound library you're using. The one Peter linked says D9 and D10, so PB1 and PB2 (pin 13 and 14). That library allows you to use the two pins together to get 16bit sound, so I'd recommend doing that, it'll sound a lot better.My thoughts on the dual chip setup so far is to have them talking over I2C. I think I'll have the main chip reading the accelerometer, and let it decide what files to play. The library Peter linked has some strict requirements on the SD card, so it'd probably better to use a discrete flash chip and have my software handle loading files. And like you said, discrete chips are cheaper and more efficient than SD cards. It may be worthwhile to do CRC or MD5 checks on the sound files after transfer. Depending on how busy the second chip is with generating sounds, I might have the main one toggle an interrupt to tell it to read the I2C bus.I get the feeling that timing things correctly to get sound matched up with actions is going to be a huge pain in the ass.My lightsaber board is open-source if you want to see how I'm doing things:https://github.com/rexxar-tc/IoDriver

author: Canobi
author_rank: Regular Contributor
timestamp: May 07, 2015, 08:17:06 pm
content: Quote from: rexxar on May 04, 2015, 01:00:08 amThanks rexxar, and it's really cool of you to make your work open source too dude, kudosWell I've been having fun completely rearranging/adding/removing components in my layout. Not easy given the restrictions I'm trying to work to (single sided, max width of 20mm, max length of 75-80mm. Turns out my favorite app won't make PDFs for anything larger than 80x80mm; total bummer).Anyway, got a few more questions I could use some clarification on if anyone can help.1. After a bit more reading it seems Li-Po voltage can be up to 4.2v max, 3.7 nominal so I'm going to need some sort of regulator for the mem/MCU rail right?2. Do I need to regulate the voltage for the data lines?3, can voltage dividers be employed for this (just learning about dividers so would a good way to get some practical in as well if they can)?4. Noticed the two XTAL pins which I assume means crystal right?5. Is an oscillator always needed for those pins or does it not matter in my case (I'm guessing 16Mhz if so since that's what the chip runs at)?6. The most common SMD crystals seem to be four pin, can these be used?7. If so, which ones go to the XTAL pins.Best candidates I've found are 3x1mm three pin on ebay but no brand name mentioned in the description and having trouble finding a data sheet for them. Next best are some two pin but they're the same size as the four pin versions @ 6x4mm which are a little big for my liking.Sorry for the barrage of question about crystals, haven't got that far in my course yet, other than they keep time, I don't know much about them yet.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 07, 2015, 10:40:57 pm
content: Quote from: Canobi on May 07, 2015, 08:17:06 pmDo any other devices on the board need a specific voltage? Check your sound chip, it could require more than 3.7v. The clock speed of the processor matters, too. Atmel's recommended operating range says you need about 4V at 16MHz. If you need to have a 5V rail, a boost supply is easy to implement. If all your devices will operate with a supply between 3 and 5V you could power them with just the battery, no regulation needed.QuoteNo, data lines will be (approximately) at the supply voltage of the device driving them.QuoteVoltage dividers can't supply much current, and when to do put a load on them, the voltage changes. If you need a particular voltage, it's best to use a voltage regulator, like the LM78 series devices.QuoteyepQuoteMost AVR chips like the ATmega328 have an internal oscillator, so you don't have to use a crystal. The 328 in particular comes out of the factory programmed to use its internal oscillator, so you don't need to have an external crystal at all.QuoteThese can be either self-contained oscillators or actual passive crystals. If you use an oscillator, connect the output to the XTAL1 pin. If it's a crystal, connect both of the crystal terminals to XTAL1 and 2, and be sure to use load capacitors. I've usedthesecrystals before.

author: Canobi
author_rank: Regular Contributor
timestamp: May 08, 2015, 04:12:37 am
content: Thanks for the detailed replyI picked componants that work at 3.6v for this circuit so I should be OK then.

author: Canobi
author_rank: Regular Contributor
timestamp: May 09, 2015, 11:25:04 am
content: OK, so I've just realised I need access to the Atmel chip in order to install sketches and such. I've opted for a mini b USB connector but the question is, will I need to protect the flash memory chip when the board is attached to a PC since its max rating is 3.6v and USB is 5v?I have an FTDI board but my guess is that that works at 5v too.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 09, 2015, 04:08:41 pm
content: Quote from: Canobi on May 09, 2015, 11:25:04 amYou've got two options here:You can use USB to program, but you'll need a USB to serial converter chip. I use the Cypress CY7C65213.Or, you can just use ICSP to upload sketches. You'll need to program the arduino bootloader (so it responds to serial) by ISCP the first time anyway.If your flash chip has a max Vcc of 3.6v, you're going to run into trouble. A fully charged lithium cell is around 4.2 volts. You might get away with using a low-dropout linear regulator, but I'd try and find a 5v tolerant chip.As for 5v from USB, you shouldnotconnect the USB power to your board Vcc. If you do, you're shoving 5v at 500 or 1000+mA, which could cause your lithium cell toexplodein the worst case. Depending on your USB to serial chip, you'll either connect it to that or leave it floating (disconnected). You might also use that to power your charging circuit, if you have one. The other thing you might want to do with the USB 5v is connect it to an IO pin on your processor, so it knows when it's plugged in. If you do that, you should set up a resistor divider to take it down to 3.3v or so, as the input voltage tolerance is Vcc + 0.5v.I've attached a PDF of my schematic. Since we're doing the same thing, you can use it as a reference, if you like.

author: Canobi
author_rank: Regular Contributor
timestamp: May 09, 2015, 07:30:00 pm
content: Quote from: rexxar on May 09, 2015, 04:08:41 pmOK, I wondered if it was going to need some extra stuff as well, not much room left to play with though. ICSP sounds interesting, how does that work?Quote from: rexxar on May 09, 2015, 04:08:41 pmAlready started looking around. All I've found so far are 4Mbit 32 pin devices. Looks like I'll need to make a micro sd breakout board or go with a voltage regulator (leaning towards the former at the moment as it would be handy to have the board down by the pommel for easy access).Quote from: rexxar on May 09, 2015, 04:08:41 pmNo worries there as the plan has always been to put the battery in its holder last minute just before installing the PCB in the hilt so it won't be on the board during the uploading procedure. I also don't need the USB for the charger ic as that was the first element I tackled so I think I'll ditch that idea for now and look into ICSP.Quote from: rexxar on May 09, 2015, 04:08:41 pmYou are a scholar and a gentleman good sir, I thank you indeed.Your input thus far has been very helpful and it is most appreciated guys, I may yet crack this which will be a huge achievement for me I have to say.By the way, do you make the hilts too, or just messing with the electronics?

author: PeterFW
author_rank: Frequent Contributor
timestamp: May 09, 2015, 08:16:33 pm
content: When it comes to regulators, usb, charging and level conversion you open a big can of worms.Once you got it down, it is easy but wrapping your head around it to begin with is a bit much since its a fairly big amount of informationI would not say that you have a problem with board space but you are not granted with a big amount either.There are a few things to consider, i would start with, how often will this device connected to a computer for data transfer and how convenient should the charging be?Charging over USB is a bit... bitchy... if you want to be USB compliant.You got in a bit of a pickle with the AtMega, i guess you need to run it at 5V since you need the 16Mhz.So... put everything that can on the 5V rail and use a boost regulator to get 5V from the Li* cell.The other 3.3V stuff you run of the Li* cell with a cheap linear LDO, that has a reasonably high efficiency. Then a level conversion between the two rails, there are plenty of different types/solutions available.I would recomment a protected 18650 cell since you got a 20mm tube, they fit in there nicely, no wasted space. You could even design the endcap to unscrew so you can change them.That was you do not need to include a charging circuit.You get 18650 chargers of the shelf at low cost, 18650 cells are popular with electronic cigarettes, you can buy them easy and plentyfull.This gets rid of the USB power connection, charging problems and you have a longer "play time" because you can easily swap batteries.Your power amp for the speakers takes a lot of power, if you want to run it of the 5V rail too.You may have to use a beefy boost regulatorThe last bit... the ISCP/USB connection to programm everything.If you got the board space i would put a CY7C65213 on there in a self powered configuration.That way you do not need to power the chip of the USB line and only connect the data lines and ground.The user can program the unit with new sounds/different behaviour that way.If you only program it once, put a few ISCP pins on the PCB and forget about the whole usb stuff.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 09, 2015, 08:34:07 pm
content: Quote from: Canobi on May 09, 2015, 07:30:00 pmIf you're not going to use a serial connection, you can't really upload data to a discrete flash IC, so using an SD card would be the way to go here. ICSP programmers are reasonably cheap these days, just google around a bit.QuoteNo, I don't have any experience with machining, although my brother does, and he modifies his hilts. My deal is you bring me a hilt and I install the electronics. (I don't actually use the sabers, my brother requested an alternative to UltraSaber's emerald driver, which is stupidly overpriced)Quote from: PeterFW on May 09, 2015, 08:16:33 pmIt's not, really. You can get charge ICs that directly do D+/- sensing, ICs that are dedicated solely to that, and the Cypress USB to serial IC I use has charger detection.QuoteYou can run the ATmega328 at 3.3V and 8MHz if you want. Currently I'm using a 5V boost converter for other reasons, but the uC is still at 8MHz. I think an LDO is probably the best option for a 3.3V rail. You could also avoid level conversion if you power the uC off the 3.3V rail. Power consumption is pretty low, so heat shouldn't be a huge issue.QuoteThis is what I'm doing. I've got things arranged so the USB port is accessible from the bottom, you just need to unscrew the pommel. Works out pretty well.

author: Canobi
author_rank: Regular Contributor
timestamp: May 10, 2015, 12:29:56 am
content: Quote from: PeterFW on May 09, 2015, 08:16:33 pmAhh, well actually I'm limited to 80mm x80mm max regardless of what board I make. I haven't got my head round desktop CAD yet, right now I'm using an app called DroidPCB for home etch enthusiasts. It's simplicity is its strength and I use it all the time as I can just pick up where I left off no matter where I am.It only makes PDFs at the moment, has a minimal footprint library/work area, no auto routing and it can't make gerber files, but for all that I can't get enough of it.Quote from: PeterFW on May 09, 2015, 08:16:33 pmTo answer the first part of the question, ideally just once. My reasoning is this. If each set of sabre sound files shared the same directory names, to change them you just change the SD card as to all intents and purposes, nothing has changed as far as the MCU is concerned. Obviously there would have to be the same number of files in each catagory for each set so the MCU picks the right sounds depending on what's been coded, and while it could be possible for the sound set archive to get confusing, a simple text file included with the sounds on the card and in the sound library folders on the PC can be used to keep track of things.To answer the second part. My idea is to have a DC socket in the Base of the pommel which provides the power to the MCP73833 to charge the battery when plugged in and I've also designed a tiny LED charge status board to fit a three leg lightpipe for charging, charge complete and fault indication (also a good way to let you know the board is still working if the LEDs come on when it's put on charge after some heavy dueling).Originally I had a 5v regulator on the input so any wall wart that fit the socket up to 18v could be used but the 73833 provides regulation up to 6v anyway so will just stick to 5v or 6v warts as removing the regulator gave me loads more room to jiggle things around.Since the battery holder will be mounted on the topside, I have to avoid anything that needs through holes underneath it so was able to move all SMD parts under it and through hole stuff either end.Quote from: PeterFW on May 09, 2015, 08:16:33 pmSince it looks like I'll be using a micro sd, that kind of sorts out the issue as it's also 5v, the flash was the only true 3v part of the circuit.I've not used a boost regulator before, I assume they're basically the same as voltage regulators but kind of work in reverse.So I'd essentially put one in series on the battery output to the MCU and card right?Quote from: PeterFW on May 09, 2015, 08:16:33 pmIntegrated charging was definitely one of the things I wanted on this board. I'm bored of unscrewing pommels, fixing over flexed/snapped wires and replacing worn screws :pMy batteries of choice are RCR123A. Been using them for a little while now and they last for ages before needing a recharge in a simple torch style sabre electronics setup.They're about the smallest battery I've found that still have a large capacity and holders for them that are PCB mount are available.Also, the main body tube I use is 25mm ID. With battery and mount on a 20mm wide pcb, the assembly just fits inside which makes things snug enough not to rattle about, but loose enough to extract should it be necessary.Quote from: PeterFW on May 09, 2015, 08:16:33 pmI assume that was aimed at rexxar as I was planning on using the ATMEL chip to drive a speaker.Quote from: PeterFW on May 09, 2015, 08:16:33 pmIf the sound file naming thing works it should only need programming once, but with the sd card on a breakout and I remove the footprint for the USB socket, there might be enough room for the ic you mention depending on its size and peripheral components that are needed.ISCP sounds the simplest solution though.

author: Canobi
author_rank: Regular Contributor
timestamp: May 10, 2015, 01:50:34 pm
content: OK, so I've just been working out how to include a boost regulator in my circuit and it looks like there are only a few options.1. Place buck in between battery and soft switch therfore providing a single 5v rail to the system. Get replacement resistors of appropriate value based on the new voltage level for the LED rail.2. Get a second regulator to make a 3.6v rail for the LED and use the resistors I already have.3. Use the uC to control the LED.Challenges are:1. LED is high power with a max rating of .7A @2w so need a boost ic that can at least give 80% of the needed current.2. Integration of soft latching switch as system on/off for either a 5v general, or 5v and 3v rail system.3. Finding a way to cram all this s**t in a very small spaceTaking a short break as I tackle some more course work < have at thee electronics, I shall see thee beaten by damn you>

author: rexxar
author_rank: Frequent Contributor
timestamp: May 10, 2015, 05:08:03 pm
content: The trick here is that you use the boost converter to power your processor and peripherals, but you power the LEDs directly from the battery. If you're ditching that 3v flash chip, you can just use a 5v boost converter like the MicrelMIC2187. This requires three passives and the inductor, and gives you a stable 5v. If you do need a 3.3v rail in the future, just stick in a linear regulator, job done.While that switcher is capable of supplying 4.8A, it's better to connect the LED directly to your battery. That way you get less heat dissipated in both the switcher and the LED current limiting resistor.Soft latching is really easy. You'll need to switch to a momentary button (rather than latched), and hook that up as an interrupt. I have mine on pin 32, which is interrupt 0. From here you can either turn the LED on or off, or put the whole system into sleep mode. I have it set up so that one press changes colors, and holding it for 2 seconds shuts everything down. The fact that the button is on an interrupt pin lets it wake the system back up.It's a challenge to get the board space down, but I managed to cram everything into 18x50mm. Of course, I've also spent countless hours working on the board (I'm on revision G right now).

author: Canobi
author_rank: Regular Contributor
timestamp: May 10, 2015, 10:35:09 pm
content: Quote from: rexxar on May 10, 2015, 05:08:03 pmSo the LED has it own rail?Quote from: rexxar on May 10, 2015, 05:08:03 pmIf there's a direct rail from the battery, do I need a 3v regulator?Quote from: rexxar on May 10, 2015, 05:08:03 pmI use 3w SMD resistors for my current limiting. As the pcb has to go in a tight enclosed space, I upped the wattage rating to compensate for the higher internal operating temp. I have a 22x50mm heat sink sitting directly under the LED as part of the assembly and the hilt itself acts as an extended heat sink.Quote from: rexxar on May 10, 2015, 05:08:03 pmHow does that work if the LED is connected directly to the battery?That would mean switching a 3v line with the ic runnung at 5v. Unless you've included a 3v post regulator in your thinking about that method, or am I missing something?I made a template circuit of a really simple soft latch so I can drop the circuit in any other design that may need it based on the first one in this list:http://www.edn.com/design/power-management/4427218/Latching-power-switch-uses-momentary-pushbuttonAt the moment it's sitting just after the battery, but was making room to stick the boost ic in series with it.It would make thing easier if the uC can act as a soft switch too I must say. It would also free up at least 18mm square on the board if I remove the circuit.Quote from: rexxar on May 10, 2015, 05:08:03 pmIf I can ditch the switch circuit mine won't be far of those dims as well. I'm on MkV revision 6.2_ARM right now. I have three different veriants on the go, but main focus is ARM as the likeliest candidate.I did have a bit of an inspirational moment whilst clearing up my workshop today.When I swim in deep water for long periods I start to get cold feet. I enjoy the challenges that electronics offer, but sometimes need to get back to a comfort zone to recuperate. I then see if I can stretch the boundaries a little more thus armed with new knowledge.Clearing up I found an Arduino pro mini (5v clone), my FTDI breakout board I mentioned (older version with header pins) and a 2w digital audio amp.The idea that came to me was to make a single link pcb for all the modules. They would simply sit on top of it attached by the pins, through hole style. They're all small enough to fit a 20mm wide pcb and together measure just over 55mm. Including the battery/charger section the board measure 75mm which is about the maximum length for hilt pcb anyway.It would achieve the same end and would give me time to wrap my head around how to include the new components and their suggested layouts in my design.It would also be a quick way to test code out in the physical world while I make my tweaks, so I'm considering it a prototype I can mess with while I learn how to code as well.Just double checking but if I break out the FTDI pins on my saber pcb uC just like the pro mini, I can use the FTDI board to upload sketches to it in the same way right?

author: rexxar
author_rank: Frequent Contributor
timestamp: May 11, 2015, 06:49:27 am
content: Maybe a schematic would explain better than words. I attached my latest one.The processor is running at 5v supplied by a boost regulator, which is driving the MOSFETs that switch the LEDs on and off. The MOSFETs are connected directly to the battery; no regulation involved. For the resistor calculation, I just assumed 3.7v. This gives relatively low power dissipation on the resistors. Because the Vfwd of the blue, green, and white LEDs are about 3.2v, I can just use a 1 ohm resistor. A 2W SMD one works just fineWhen you turn the saber off, the processor goes into sleep mode. Right before it does that, it drives all the MOSFETs low, which cuts supply to the LEDs. This is, in effect, soft latching. If you're going to use a processor anyway, it makes the most sense to use that to do your latching, rather than waste board space with a discrete circuit. You can do it in just a dozen or two lines of code.QuoteThis is basically what I've done. The base board has a connector that acts as an expansion bus. The sound board plugs into that, and has some screws for mechanical support. The idea here is that users can buy the expansion modules separately and install them on their own. Of course, if you're just doing a one or two-off for yourself, soldering pins across the boards works just as well. For reference, my base board is 18x50mm, and the sound board is 18x40mm. You save a lot of space when going into the third dimensionQuoteYes. However, you need to first program the Arduino bootloader before it will respond to your serial commands. Since you have another Arduino board, you can use that as an ICSP programmer, just ask the Google, and you'll find a tutorial quickly.QuoteAs far as I know, ARM architecture isn't supported (natively) by Arduino. I think all the boards are AVR type processors. You might be able to find a custom bootloader for your processor, though.

author: Canobi
author_rank: Regular Contributor
timestamp: May 11, 2015, 11:31:30 am
content: [quote author]Maybe a schematic would explain better than words. I attached my latest one.Some do, though I'm not that proficient at reading them as yet.Quote from: rexxarOK, I'm starting to get it now. So it's actually the same as the soft latch, just part of the circuit resides in th uC. Very neat solution, I just couldn't work out how it operated before.Only just learned about fets and haven't quite assimilated them into my thinking properly yet.Back to the schematic. what is J1?Are all the fets used as part of the switching circuit?If not, which one goes to the led and what brand of LED are you using?I like the idea of being able to change the colours, saves me having to stock a range of them as I do now. Changing colours on the fly isn't a top priority for me unless the uC can do that. Hard wiring one of the colours would do for now.Quote from: rexxarWell I never. I was starting to think I was cheating a bit by doing that, but it makes more sense for my level of skills at the moment. Work on a dedicated pcb will still continue, but at least I can start getting some hands on with it all.[quote author = rexxar]QuoteYes. However, you need to first program the Arduino bootloader before it will respond to your serial commands. Since you have another Arduino board, you can use that as an ICSP programmer, just ask the Google, and you'll find a tutorial quickly.I only have the one clone pro mini at the moment, though I'll be getting more if it works. My concern is that I have the 5v 16Mhz version and I keep reading that the FTDI is 3v. Will the breakout still work with it?[quote author = rexxar]QuoteAs far as I know, ARM architecture isn't supported (natively) by Arduino. I think all the boards are AVR type processors. You might be able to find a custom bootloader for your processor, though.Yep, my mistake. I meant to say AVR

author: rexxar
author_rank: Frequent Contributor
timestamp: May 12, 2015, 04:56:49 am
content: Quote from: Canobi on May 11, 2015, 11:31:30 amJ1 is the connector out to the LED. The FETs drive the LED. It lets you switch high currents (nearly 1A in this case) with the processor.The LED I'm using is from Ledengin. It's in the LZ4 series, I believe. It's fairly expensive at $22, though.QuoteChanging colors on the fly is the whole selling point of my board. My partner wrote the code that does that bit, but I think it was fairly simple. He wrote a PC side GUI program and everything for it.QuoteNah, it's done all the time, especially in space-constrained devices. Dave's done teardowns of some handheld items with multiple boards stacked.QuoteI'm honestly not sure. You can get level shifters relatively cheap, but it might be easier to just get a 5v version of the FTDI board.QuoteWith all these new acronyms being shoved into your brain, I'd expect you to mess one up now and again, no worries

author: Canobi
author_rank: Regular Contributor
timestamp: May 12, 2015, 11:56:17 pm
content: So it looks like my setup will be modular due to board size restrictions but it's not a big deal. Actually it's kind of handy as I've reworked an older revision of my board which is now the main PSU for the bus board. Best bit is it can also function on its own and can just be used as a mini charger while connected to DC.There's quite a bit of floor space under the battery now so I may have a go at tackling the fet array from your schematic rexxar. I have two rows for header pins on the input of the bus board, one for connecting the PSU, the other is FTDI. As the PSU only uses two pins, the rest can be for connecting the fets to uC.One thing though, I can't seem to find the MIC2187 on RS, mouser or digikey and I've been having difficulty choosing the right boost regulator as there's quite a few types. I started toying with an alternative idea of using two Li-Po cells, swop out the charger ic for an appropriate one to and use a 5v regulator on the PSU output and a 3v3 on the bus board for the LED. Downside is it increases the overall length by another 45mm for the extra cell as there's no mountable duel cell holders for them.I vaguely recollect that the CR123As are a half size cell. I wonder if two would fit in a full size holder and if someone makes a mountable version if they do......Anyway, I've attached a pic showing my modular system as is, though the bus board isn't to scale.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 13, 2015, 11:22:29 pm
content: Quote from: Canobi on May 12, 2015, 11:56:17 pmI usetheseFETs. They're super small.QuoteThat'd be because the MIC2187 doesn't exist, I gave you the wrong part number!TryMIC2876QuoteThere's no real advantage to doing that. You lose space, and cut your battery capacity in half (because capacity is only additive in parallel configurations).

author: Canobi
author_rank: Regular Contributor
timestamp: May 14, 2015, 12:23:30 am
content: Quote from: rexxar on May 13, 2015, 11:22:29 pmThanks for the link, will orderr some of theseGlad it's not just me miss naming stuff then, I wondered if the part number was right lol.The CR123A cells I have are rated at 2300mAh, but Yeh, the extra length and having to refigure the charging components probably isnt worth it.

author: Canobi
author_rank: Regular Contributor
timestamp: May 14, 2015, 10:13:57 pm
content: Getting there with my layout slowly. Haven't tackled the fet array yet, but I've finished the micro sd card breakout board and started routing the bus board.Back to sound, I seem to have come to an impass. Looks like PB2 which I was going to use for driving a speaker is also the SS pin which I've already routed to the sd card.Are PB1 and PB2 used as inputs for an audio ampifier as well, or will any pair with PWM be OK?Can a different pin be used as the SS for the card?I've attached an sd card to arduino routing schematic I've been using as my reference and a micro sd card pinout to cross reference, though there seems to be a small discrepancy between the two so not sure which one is right.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 15, 2015, 02:54:18 am
content: The SS pin is forslaveconfiguration. You can use any pin you like for CS (except SS). Here's a snippet of code from my routine that reads an SPI EEPROM:Code:digitalWrite( PIN_CS_E, HIGH ); //CS high is default stateSPI.begin();SPI.setBitOrder( MSBFIRST ); //SPI config stuffSPI.setClockDivider( SPI_CLOCK_DIV2 );SPI.setDataMode( SPI_MODE0 );digitalWrite( PIN_CS_E, LOW ); //pull CS low to activate EEPROMSPI.transfer( 2 ); //select write modeSPI.transfer( address ); //send addressSPI.transfer( data ); //send the datadigitalWrite( PIN_CS_E, HIGH ); //pull CS high to disconnect and begin write processYou have to manually toggle the CS pin every time you want to connect to a slave device. You shouldn't set up SPI withCode:SPI.begin(10);You want to start inmastermode, so you don't want any value in the parentheses.In case you don't know:MISO stands for Master In, Slave Out. So, Data Out on the SD card would go to MISO on the processor.Similarly, MOSI stands for Master Out, Slave In. So your DI line goes here.Unlike RS232, where Tx on one device connects to Rx on the other, with SPI you connect MISO to MISO and MOSI to MOSI. This tripped me up a few times when I was first learning how to use it.The first image you linked is the pinout for a full-size SD card, which is why the pinout is slightly different. Be sure to use the pinout from your second image, it's actually for a microSD.

author: eosintickleear
author_rank: Newbie
timestamp: May 15, 2015, 06:27:33 am
content: Glad to see this posts.I alomst reading each reply by rexxar, also PeterThey have many good suggestions and many useful links. It can study well from themAnd for the sound process, SD card would be a goood choice. Easy to handle.As I am a newly in electrical design, it is really very useful for me.Here as I read that you have applications of PCBs, I can share one fab. which hope it can be useful for Canobi.pcbway.com/e,Following is the PCBs I ordered last month, 2 kinds, the blue is 2layer,1.6mm Blue sold mask. It is like the size of a coin. And the Red PCB is 4 layer, Red sold-maske. Feel good.And Erin shows me very good service. Share here for every guys.Good luck for your design, CanobiEosintic

author: Canobi
author_rank: Regular Contributor
timestamp: May 15, 2015, 08:43:02 am
content: Quote from: rexxar on May 15, 2015, 02:54:18 amI'm sure it was mentioned, but thanks for doing so againQuote from: rexxar on May 15, 2015, 02:54:18 amYay, something I actually know for onceQuote from: rexxar on May 15, 2015, 02:54:18 amOK, so maybe not as much as I thought. Seems a bit counter intuitive, makes more sense to have labelled it the same way as RX/TX. Will need to swop the routing to those pins now.Quote from: rexxar on May 15, 2015, 02:54:18 amI did wonder, so I'm thinking I may need to change the values of the resistors as the schematic shows a 3v rail to the card, not 5v.Also just to check, are PB1 and PB2 ok go to the amps line in and I can use any another digital pin as CS?

author: rexxar
author_rank: Frequent Contributor
timestamp: May 15, 2015, 03:28:22 pm
content: Yes, you have to use PB1 and 2 for the audio. You can use any other pin you like for the SD card's CS line. In your setup() function though, be sure to doCode:pinMode( SD_CS, OUTPUT );digitalWrite() issupposedto call pinMode, but I've found that it sometimes doesn't. You can get some weird behaviors if you don't correctly configure this.

author: Canobi
author_rank: Regular Contributor
timestamp: May 15, 2015, 09:51:38 pm
content: Quote from: rexxar on May 15, 2015, 03:28:22 pmOK, got it. Thanks for confirming thatAs a side note, I was browsing around for mono amp modules last night as it seems a waste to put a stereo amp on the bus if only one channel is being used. Oddly I only found one vendor that makes them, but luckily they're really small. I'll stick the link here in case your interested:http://m.aliexpress.com/item/1039047060.html?productId=1039047060&productId=1039047060&productSubject=2pcs-lot-3W-mono-USB-powered-5V-D-Class-A-digital-amplifier-board-Power-supply-DC&productSubject=2pcs-lot-3W-mono-USB-powered-5V-D-Class-A-digital-amplifier-board-Power-supply-DC&tracelog=wwwdetail2mobilesitedetail

author: Canobi
author_rank: Regular Contributor
timestamp: May 17, 2015, 02:04:23 am
content: @rexxar: I was just going over your schematic regarding the fets and it occurred to me that I only have single colour LEDs (at the moment anyway). Do I need to use all the fets or can I omit some? If so, which ones?One more question about PB1 and 2. The audio amp requires a live and ground per channel (not saying you didn't know this, just running through the sequence), do either of the PB lines act as ground in this case, or am I missing something (again)?I get that each is 8bit and together make 16bit but not sure how it relates to ground for the amp module.Part of me wanted to put one on each stereo channel and use common on the inputs, but after some more thought it didn't seem right as that would equate to 8 bit stereo on the output, not combined 16 bit.For a mono amp logic dictates as you stated, one on each of the inputs, just can't quite wrap my brain around it, but that's how it's routed for now anyway.Talking of mono amp modules, they're only 12 x 6.5 mm. I managed to shorten the bus veriant using the footprint for that one by quite a bit, it used to be the longest section. If I can work out the fet situation I can most likely shorten the PSU section too.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 17, 2015, 05:11:39 am
content: Quote from: Canobi on May 17, 2015, 02:04:23 amNah, you just need one FET per LED die. I need to control four LEDs individually, so I have four FETs to switch them. If you just have one color, then you just need one FET.QuoteGenerally it's fine to just tie all the grounds together. This has some special purpose in audio circuitry that I don't know a whole lot about, but just tying all the grounds together should be fine in your case.QuoteCorrect. You need to combine and filter the output from the uC before it goes into the amp. I suppose technically you could do the combination and filtering after the amp, but you'd probably get poor results.QuoteLook at it like this: you can take an 8-bit byte and represent 256 unique values, right? If you take that number and convert it into a voltage, you can make a sine wave (or any wave) by outputting the correct voltage at the correct time. However, since you only have 256 values, your resolution is very limited. Your wave will be really blocky, and it will sound, well, like 8 bit. If you have 16 bits, however, you now have 65,553 unique values! With that much resolution, you can generate a pretty clean waveform that will sound nice. What the SDAudio library does is use one output to represent the lower 8 bits, and another for the higher 8 bits. If you add these together, you can get close to the full 16 bit resolution, leaving you with a nice clean audio waveform. This isn't exactly what's going on in this library, but it's close enough to give you an idea how it works.QuoteI really can't tell what you're doing with your board layout. :\ What's going on in the center row? The middle one is the SD card, but what's the thing on the left? Pullups? Or some sort of R/C thing? I guess the one on the right is a headphone jack?OH. You're using a premade Arduino board, aren't you? That explains why I don't see a footprint for the ATmega.It looks like you have some holes connected directly to the ground plane. You really want to add thermal reliefs on those. You have a huge mass of copper pulling heat away from your iron, it will be very hard to solder those pins. Same goes for the SMD parts. I'm kind of surprised your program didn't add those automatically.

author: PeterFW
author_rank: Frequent Contributor
timestamp: May 17, 2015, 06:08:34 am
content: I can no longer tell who does what, were or when and i have to admit i do not want to read the whole thread again.But...It looks like you are routing the board as you go alog, without a prototype.That will bite you in the arse if you have not build this circuit.If would adivse you to put everything at least on a protoboard or breadboard before routing and spending too much time on the schmematic.At first, make shure everything works, then comes the board.You will spend the same amount of time cutting and rewiring your first PCB if you do not build a prototype first.This is a very simple circuit, it should not be a problem make a rats nest of wire on a proto board.

author: Canobi
author_rank: Regular Contributor
timestamp: May 17, 2015, 09:39:14 pm
content: Quote from: rexxar on May 17, 2015, 05:11:39 amI thought that might be the case. The schematic shows a couple of them linked to the uC pins, which one do I go for if using just one fet?Quote from: rexxar on May 17, 2015, 05:11:39 amAnalogue circuits sound pretty complex from what I've garnered so far, one of the reasons I opted to use an amp module so I didn't have to deal with special layout considerations.Quote from: rexxar on May 17, 2015, 05:11:39 amIf combining the output happens prior to the amp, is that done via code or componants?Quote from: rexxar on May 17, 2015, 05:11:39 amGreat explanation, totally get it nowQuote from: rexxar on May 17, 2015, 05:11:39 amOne on the the left is the charge status LED board. Initially I was going to use low volt through hole LEDS so I could mount the pm directly in the hilt. They didn't work on my proto board and found that SMDs did, so my only other option is to use light pipes.As luck would have it, one of the A/C drives we started manufacturing for Eaton at work has triple spot light pipes and early plastics were a complete disaster at the assembly phase so managed to harvest quite a few from the plastic scrap bins.The one on the right is for the tactile momentary pushbutton switch and the two "wings" with the holes are bolt for mounting it to the hilt.Quote from: rexxar on May 17, 2015, 05:11:39 amYes, while I still have the file for an on board uC, I thought it might be be good idea to make a working proto using the arduino I already had since everything between the charger/PSU and LED are new to me.Quote from: rexxar on May 17, 2015, 05:11:39 amNever needed them before as all the boards I've made so far have been pretty small, and mostly simple enough not to need ground planes. Only just changed to photo etch resist too, toner transfer doesn't like large ground planes, the excess ink make things shift around and smudge regardless of how careful I am.Thanks for bringing it to my attention, advice like that is gold dust, so will be implimenting them from here on in. The devil's in the detail at the end of the day

author: Tombs Balsam
author_rank: Newbie
timestamp: May 18, 2015, 02:56:39 am
content: Quote from: eosintickleear on May 15, 2015, 06:27:33 amit is a good suggestion for me. I am just want to look for a fab in China.I will try withwww.pcbway.com/e, hope it be my good choose for my PCB.Thanks for sharing.Tombs

author: miguelvp
author_rank: Super Contributor
timestamp: May 18, 2015, 03:18:10 am
content: Myis pegged at 11.https://www.eevblog.com/forum/projects/do-you-flood-your-pcbs/msg675414/#msg675414Edit, adding quote from other thread:Quote from: Tombs Balsam on May 18, 2015, 03:05:37 amYou need one and also recommend it within minutes? Same registration date as the other poster?There is no need to try to trick forum members, just post on the buy sell or on the pcb manufacturers section with no tricky businesses.Quote from: Tombs Balsam on May 18, 2015, 02:56:39 am

author: Tombs Balsam
author_rank: Newbie
timestamp: May 18, 2015, 03:57:08 am
content: Quote from: miguelvp on May 18, 2015, 03:18:10 amYour analysis sounds reasonable. But it is funny in the results.Cause I am not a fab.

author: miguelvp
author_rank: Super Contributor
timestamp: May 18, 2015, 04:06:19 am
content: Quote from: Tombs Balsam on May 18, 2015, 03:57:08 amReally?https://www.eevblog.com/forum/projects/metal-core-pcb-prototyping/msg675430/?topicseen#msg675430Quote from: Tombs Balsam on May 18, 2015, 03:45:05 am

author: Canobi
author_rank: Regular Contributor
timestamp: May 18, 2015, 01:54:46 pm
content: Thanks for the tip, however, I'm not in need of a PCB fabrication house, I have my own PCB fabrication facilities at home which I put to good use.I have agree with Miguelvp now I've had a deeper look, too many coincidences to be lagit. As he says, post on the manufacturers section(wow, never been thread jacked before, first time for everything I suppose).

author: Canobi
author_rank: Regular Contributor
timestamp: May 18, 2015, 06:26:59 pm
content: Quote from: PeterFW on May 17, 2015, 06:08:34 amI did make a proto board for the charger circuit, but had help translating datasheet info into real world from the techies at work.The hurdle for me regarding breadboarding is almost every component I have in my workshop is SMD.However, your right, I should be prototyping for the rest as well. Necessity is the mother of invention they say, and you've sparked an idea that will allow me to follow your sound advice regardless.I've made a few bits of PCB fab equipment which I've wanted to test out including a reflow hot plate, auto PCB drill press, fume hood with HEPA filter and an exposure box. Annoyingly I haven't had anything to etch recently in order to do so, this would be the perfect excuse to knock up a plethora of discreat SMD component breakouts so I can use them on a breadboard, win win

author: PeterFW
author_rank: Frequent Contributor
timestamp: May 18, 2015, 07:25:03 pm
content: Quote from: Canobi link=topic=46652.msg675814#msg675814I will take some pictures for you, i think it is easier to explain that way how you can prototype pretty quick using SMD parts *and* have a easy job of recycling them.This is the frankensteinian thing i got sitting on my desk at the moment:Everything is seperated into blocks, each block holds one components with the external or additional circuitry.Every pin if available on a pin header, those pin headers are so damn cheap on ebay thay you can you throw them at a circuit with a shovel.Then everything is put on a cheap protoboard.My apologies of not unplugging the TQFP 144 board, it is a bitch to get outSome of the SMD boards are home etched, some i had done at a fab house and some are just straight of ebay.One board holds the USB interface, one board the Li* charger, one the Li* protection, one the power selection, one for the dc-dc converter, sd-card, real time clock and so forth.That way each component/circuit can be tested individually and then be addet to the "bigger picture" once i know it is working.The sub-assembly boards can easily be used in the next project since they do not hold anny aplication specific wiring.The whole mess is wired with enameled wire on the back, once you get that down it is very fast and simple.There are other way to do this, but since i tend to make stupid mistakes from time to time it is very, very easy to pinpoint a problem.I just have to unpluck the board, test if and i know if it is my wiring or the component.Of course, this is not suited for high frequency stuff but my SPI bus is routed everywere along the bottom side of that board and is working just fine at 4 Mhz clock speed.You can even run a decent amount of power this way, the only limiting factor is the resistance of the female headers.I got plenty of those small smd boards with various other stuff in my parts bin. Different dc-dc converters, sensors, displays, buttons, processors and so forth.You just have to keep track of the wiring, i use just a pice of paper and a pencil.Since each component is just a "block" you do not need to scribble a real shematic.At the end you transscribe that into a real schematic, i just cut and paste each sub components into the final one and wire them up.

author: Canobi
author_rank: Regular Contributor
timestamp: May 18, 2015, 07:58:43 pm
content: Quote from: PeterFW on May 18, 2015, 07:25:03 pmNow that's the kind of prototyping I can get behindWhen you said birds nest of wires, I was picturing something like this:

author: Tombs Balsam
author_rank: Newbie
timestamp: May 19, 2015, 02:02:21 am
content: Quote from: miguelvp on May 18, 2015, 04:06:19 amAgain that I am not a PCB fab, just a PCB customer.Please do not like a "police" , thanks!

author: Canobi
author_rank: Regular Contributor
timestamp: May 22, 2015, 08:46:53 pm
content: So I took a closer look at the mono amp and noticed there's a CS pin. Is that "chip select" for some kind of sleep mode perhaps?

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 22, 2015, 11:04:04 pm
content: If you knew what chip it is using, you could look it up in the published data sheet.Do they provide any documentation at all?Could it be "GS" (gain select?)There have been many 1-channel (monaural) chip amps from all the way back to the LM386 and before.For that matter the venerable LM386 is a long-time favorite of hobbyists and now available in SO package SMD.

author: Canobi
author_rank: Regular Contributor
timestamp: May 23, 2015, 10:59:41 am
content: Quote from: Richard Crowley on May 22, 2015, 11:04:04 pmUnfortunately I couldn't find any documentation on the site and there's no markings on the chip that I can see in the provided pic (it is from Aliexpress though).Definitely looks like a C not a G which would make more sense given that it's an amp.Thanks for the LM386 suggestion, will look into that one as I want to keep things as small as poss.

author: rexxar
author_rank: Frequent Contributor
timestamp: May 23, 2015, 06:18:02 pm
content: I've been looking around to see if there's another amp similar to yours with a CS pin. The only references I can come up with have the input decoupling capacitor labeled as CS. Is CS connected to a different pin than +5v?I'm willing to bet money that the chip you bought is a knockoff of some other branded device (which is why it has no markings). Given how popular it is, it's not too unlikely that it's actually an LM386 clone. I say pull up the datasheet and compare the pinouts. The 386 has a separate bypass pin, so maybe someone labeled it CS instead?

author: Canobi
author_rank: Regular Contributor
timestamp: May 23, 2015, 08:15:35 pm
content: Quote from: rexxar on May 23, 2015, 06:18:02 pmYeh CS is a separate pin by the looks.Quote from: rexxar on May 23, 2015, 06:18:02 pmI haven't actually got it yet, though that module is the likeliest contender. I do have a micro stereo amp, though the mono is much much smaller again. Documents aren't available for the module from the site, though I did download the data sheet for the LM386.It looks simple enough and it only needs a few extra componants too which is a bonus, though unlike the other ICs I have so far, there wasn't a PCB layout suggestion in the datasheet I found.Haven't tackled analogue before, can I get away with it on a single sided pcb?So far I've reworked the control bus layout to include the direct rail from the battery to LED (for the transistor it's live from battery to collector, drain to LED, Base to uC right?).I also shuffled some of the SD card connector pins on the control bus for better track routing arrangement, then redid the sd card board to match them up. Didn't need much doing as it happens, the change only effected two tracks overall.Added the 2w SMD resistor footing which I'd forgot to include (duh), and labeled the FTDI pins for easy identification.It helped to reread the thread a few times, lots of overlooked gems have been garnered. One thing I couldn't find any details on though was the actual pushbutton arrangement and what pins its connected to.Regarding rail splits which I'm not used to either, do it need a diode going to the 5v rail so it doesn't feed into the 3.7v rail?Taking the most common dropout voltage as worst case if I do (about 1.2v), that would mean the boost regulator would only get around 2.5v, is that going to be enough to drive it at 5v?

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 23, 2015, 11:42:51 pm
content: Quote from: Canobi on May 23, 2015, 08:15:35 pmThose things are very simple and forgiving. Sure you can use a single-side PCB. They were introduced decades before SMD technology was developed. It is probably one of the simplest parts of your project. Don't sweat it.

author: Canobi
author_rank: Regular Contributor
timestamp: May 23, 2015, 11:47:39 pm
content: Quote from: Richard Crowley on May 23, 2015, 11:42:51 pmSweet, thanks RichardI found the post regarding the buttons pin connection, pin 32 (I'm assuming the other goes to ground right?)

author: Canobi
author_rank: Regular Contributor
timestamp: May 24, 2015, 11:05:58 am
content: After Peter mentioned miss wiring, I thought I'd go over the pro mini specs again to reacquaint myself with it (confidence is a good thing, but it can overstep the mark if left unchecked, guess what..?). Well so much of it starting to make more sense and I realised I'd made a minor mistake regarding choice of power input line.Kind of thinking aloud here but there are 3 power line inputs that I can see on the pro mini: 2x Vcc and RAW. If I understand correctly what's said on the Sparkfun website, RAW is a line in to the on board regulator, so anything from 3.4v up to 12v can be used while both Vcc lines are 3v3 only.Now, I'll have 5v and 3.7v rails once I've added the boost regulator to the PSU module. Max rating for the 3v3 lines is 3v6, Li-Po cell can max at 4v2. I'm guessing that using the lip direct rail won't work with RAW as the dropout would effect operation once the cell falls below optimal Vf.Regulating the 3v7 rail for using the 3v3 line would suffer the same problem, and take up space/time.That leaves the 5v rail to RAW in as the most logical choice then I think.One of the 3v3 Vcc lines looks to be for the FTDI pins. I'm assuming it's power comes from the FTDI basic breakout board when connected so don't need to worry about connecting it from elsewhere.At some point I need to add an MMA8452Q module to the control bus. Unfortunately, it's a 3v3 tolerant device which will also need regulated power from the PSU module. I could make another rail from the 5v to a regulator for the accelerometer. There's still some unused pins on the PSU header connector.Just out of interest, anyone know if there are any dedicated PCB to PCB interconnectors out there?Headers are OK to a point but from a durability point was thinking about trying to find something a little more secure to attache them together with. Kind of like lockable/latching ribbon cable connectors (though right angle mount and without the ribbon).

author: PeterFW
author_rank: Frequent Contributor
timestamp: May 24, 2015, 12:47:42 pm
content: Quote from: Canobi on May 24, 2015, 11:05:58 amBoth VCC pins are on the same net, both are connected to the output of the regulator.You can supply a external 3.3V supply there, but it is not all that nice to the regulator.At least i have not killed one yet or seen a significant current draw, but i only use chinese clones.QuoteYou can just connect the Li* Cell directly to the RAW input pin, there is a voltage drop but for a simple "toy" you do not need to worry about that.Most likely every component on the 3.3V rail will work from 3V to 3.3V and the discharge curve of the Li* cell is nearly dead at 3.5V annyway.I do not know what sort of LDO is on the board but i suspect is will work just fine, that is plenty of head room.QuoteYes, there are in fact so many that i do not know what i should recommend

author: Canobi
author_rank: Regular Contributor
timestamp: May 24, 2015, 08:57:13 pm
content: Quote from: PeterFW on May 24, 2015, 12:47:42 pmI think mines a clone, are there any notable differences between the clones and officials?Quote from: PeterFW on May 24, 2015, 12:47:42 pmI've been trying to sort out who needs what and from where properly. I was aiming at making it a 3v exclusive system, but some component modules run at 5v (culprits are: pro mini, amp module, FTDI basic breakout board and SD card).My thinking is use the 5v rail for the above list of culprits, and the 3v rail for the LED and accelerometer module.Quote from: PeterFW on May 24, 2015, 12:47:42 pmGreat stuff! Well to narrow it down a bit I'm after lockable/latching single row-right angle pcb mount connectors with anything up to 10 pins at 1mm or 1.27mm pitch that can carry 1.2A @12v.

author: Canobi
author_rank: Regular Contributor
timestamp: May 25, 2015, 11:25:36 am
content: So I've moved a few things around and opted to use a few more jump wires to keep things simple and as tidy as possible on the PCB.Funny how it looks so daunting when first starting out but in reality it's not as complicated as all that. I just needed to get who's connected to who down pat and check if any in line components are needed from pin to pin (like the I2C SDA SCL pins).Lots of cross referencing goes a long way too, constantly on the sparkling website and anywhere else I could find the info I needed to hook things up right.I'm plonking the latest screen grab of my control hub module here for comments and teardowns (I realise I'm still learning so there's bound to be some aspect in the design I missed, just don't shoot me down in flames without at least adding some useful criticism lol).With luck it'll be pretty close so I can make any minor tweaks and move on to working out the boost regulator circuit for the PSU module.

author: Canobi
author_rank: Regular Contributor
timestamp: May 26, 2015, 01:51:46 pm
content: Never mind, need to make some changes again after more fact finding. Looks like micro SD cards run at 3.3v. I wanted to reassess the whole rail setup anyway so that's the perfect excuse.Also, in order to make this more accessible as a home brew project, and to stick to the overall theme, I'm opting for a micro boost buck module.At some point I'd like to tackle two sided PCBs and a boost module of my own is a good one to nail as it covers many aspects of PCB layout design.Anyway, as always, there are the onligatory options for routing and the need to work out which is the best way to go.My list of modules and power requirements are as follows:Arduino Pro mini = 3v3/5v can be either by on board jumper setting.Pro's: operates at higher frequency, can provide 3v3 output rail.Con's: requires more power overall, level shifting/regulation required to communicate/interphase with 3v device.amp module = 5vMicro SD card = 3v3Accelerometer = 3v3LED = 3VLooking at that list, it would make more sense to have the whole system run at 3v3 and just use the buck for a 5v rail to the amp. Might even make an audio bus PCB just for those two and free up the control bus PCB floor space.It would make interphasing all the other stuff a lot simpler from what I gather, a 3v3 LDO on the battery rail should do the trick. I can live with the slower speed.On problem is did encounter that's bugging me is it seems I've overbooked my two interrupt pins (32 and 1).I've attached a pic showing that section on my layout, and an arduino pinout. The pins boxed in blue are the pins in quiestion, the pin boxed in red is the one in need clarification on.Can that pin be assigned as an interrupt?

author: PeterFW
author_rank: Frequent Contributor
timestamp: May 26, 2015, 03:40:32 pm
content: Quote from: Canobi on May 26, 2015, 01:51:46 pmYep, SD cards are not 5V devicesThere are some ways to tackle the problem of multiple supply voltages, batteries and regulators.Take stock wich component runs at wich voltages, chosse the one that most run on and then try to condense everything else onto as few as possible. And then comes the problem, were to get those voltages and how.You are on the right track so far, i try to make everything 3.3V and pick components accordingly. That seems to be a good choice for you as well at the moment.But everything but the LED and the audio part on 3.3V.The LED should run straight of the Li* cell, because that is the component that consumes the most power ans should work as efficient as possible.The Amp needs higher voltage or lower impedance speakers, i can not think of a way to solve that problem that is simplet then using higher voltage and a standard speaker. You got that right so far as wellAnd chances are good that you might not need anny level translation at all, the Mosfets for the LEDs will work with 3.3V on the gate if you pick the right part.The audio amp is unidirectional and depending on the driver stage you might have to attenuate the signal.QuoteInterrupts are a whole nother rabbit hole, those two pins are the external interrupt pins that can be configured to be toggled on a falling or rising edge. And they can be set up to trigger on a low or change.But, every other pin on the ATmega328p can be configured as a change interrupt, there is a PCInt library available.It depends what kind of interrupt you need/want.To wake up the µC from a power down mode, you have to use either pin 2 or 3 since a PCint will not wake the µC from that sleep mode.But you could let the watchdog timer run, this will wake up the µC on a regular interval, then you can pull a button state to determine if you want to wake up or sleep.How, what or wich interrupt you use is dependent on what it should do.As to your question, i have to admit that i dit not fully understood what you wanted to know, i hope this answer helps

author: Canobi
author_rank: Regular Contributor
timestamp: May 26, 2015, 05:15:41 pm
content: Quote from: PeterFW on May 26, 2015, 03:40:32 pmThat must be the normal SD cards that are 5v, as well I checked then lol.As to the voltage conundrum, it's just as well I really like puzzles, would have given up long age otherwise .Quote from: PeterFW on May 26, 2015, 03:40:32 pmOK that's starting to make more sense. So basically, as the LEDs max Vf is 4v, it only need the current regulating. I can go straight to the fet from the battery to the LED as the fet has a higher max rating.The one part that still confuses me is the schem doesn't state whether it's the positive or ground going from the cell to the fet/battery.The uC controls the gate right?Quote from: PeterFW on May 26, 2015, 03:40:32 pmNo matter, I think the audio bus module could be the way to go. It does mean one more satellite board, but I may be able to stack that and the micro SD card breakout, if I get the right size plastic spacers, the edges of the PCBs will hold it in place inside the hilt.Quote from: PeterFW on May 26, 2015, 03:40:32 pmWould you mind elaborating on this a bit please. I get the level translation bit (no high voltage or spikes to worry about), but my understanding on the use of mosfets is still a bit vague.I kind of understand it's use as a switch, but the level of complexity is almost exponential when more than a few are thrown in to the mix, especially when there's more than one way to use em.Quote from: PeterFW on May 26, 2015, 03:40:32 pmMy plan was to go straight from port 9 and 10 to the amp module input pins, then from that to 28mm 3w 8 or 4 ohm speaker (can't remember off the top of my head, will check in a bit).I ssume then there is either a phase veriance that need correcting, or the signal prior to amplification needs correcting in some way. Again I'm a bit lost on how to do this, though I'm guessing some resistors and capacitors come into it somewhere (they almost always do it seems).QuoteInterrupts are a whole nother rabbit hole, those two pins are the external interrupt pins that can be configured to be toggled on a falling or rising edge. And they can be set up to trigger on a low or change.But, every other pin on the ATmega328p can be configured as a change interrupt, there is a PCInt library available.Ahh, I was going to ask about the PCInt column I boxed in boxed in gray. So they can all be change interrupts then, coolQuote from: PeterFW on May 26, 2015, 03:40:32 pmWell, it sounds like I've used the right pins then. I was hoping for power down/up mode from the button and use the other two as change interrupts for the accelerometer. One to operate at the low Gs for the sweep sounds, the other at high G for activating the impact sounds.As to your question, i have to admit that i dit not fully understood what you wanted to know, i hope this answer helpsSorry if my questions are confusing at time, my head doesn't think in straight lines the whole time and I sometimes get rhetorical as something will come to me as I'm writing and it ends up being more a "note to self" than the actual question I started out asking.But on the whole, you have indeed answered many of them. Thank you for the input so far guys, you rock

author: Canobi
author_rank: Regular Contributor
timestamp: May 27, 2015, 10:02:46 am
content: EBay turned up two of the smallest boost buck modules I've ever seen. Given their tiny size, it might not be necessary to make a separate audio bus board.There is a tradeoff between the two though, the smallest is only able to output a max of 500mA, while the larger can output 1A, it's twice the width.According to Ohm's law: E=5v P= 3W, therefore I = 600mA that the mono amp draws to work properly.The smallest would be the one to go for as far as dims and fitting it on the control bus PCB, but it's occurred to me that the amp would be straining the module trying to draw more current than it would be getting, the 1A module would provide a 400mA overhead so wouldn't struggle in the least so looks like the winner in this head to head.It's a little too big to fit the control bus but I can live with the compromise I think.

author: Canobi
author_rank: Regular Contributor
timestamp: May 31, 2015, 01:45:05 am
content: Well that was a lesson in patience for me. While making the last minor change to the control hub and PSU modules, the files got corrupted and I had to start over with both of them.Didn't take long though as I'd taken the precaution to make a footprint template for the pro mini and labeled the pin to pin connections and made a circuit template for the charger (useful as I can drop it into any project I'm working on).I removed the amp module from the control bus as well and stuck it on a seperate board together with the voltage boost module as a satellite pcb. It meant I was able to shorten the control bus and rout power to the accelerometer up front, so no bad thing.Here's a composite pic showing the PDFs and work files of each module (sorry for the large pic, some of the words become illegible when downsized):

author: Canobi
author_rank: Regular Contributor
timestamp: June 01, 2015, 08:53:28 pm
content: Hi guysBeen having a closer look at coding more indepth recently. While the the logical language structure and pin designation and whatnots is pretty straightforward, I'm definitely going to need to learn how to string stuff together.Reading through example code and other templates and such I see a lot of what appear to be notes.... ///blah blah blah///....scattered about.Does this use up available memory?From what I gather, void loops are the action commands and anything written inside the () symbols are considered as such by the uC.So is there a limit to the amount af bracketed instructions, and where they are placed within the code map?Are all written text within the brackets treated as one in that uC looks at all of them and decides which one to use??

author: Zero999
author_rank: Super Contributor
timestamp: June 02, 2015, 08:01:44 am
content: Quote from: Canobi on May 27, 2015, 10:02:46 amWatch out for the peek current.3W RMS of audio will be 6W peak which is 1.2A.You could use an 8 Ohm speaker and the peak current will be below 600mA, especially if you don't drive it to full peak power which you shouldn't anyway, otherwise it results in clipping and distortion.

author: Canobi
author_rank: Regular Contributor
timestamp: June 02, 2015, 10:03:34 am
content: Quote from: Hero999 on June 02, 2015, 08:01:44 amThanks for pointing that out hero999, I wasn't aware of my minor errorThat's kind of interesting actually. My initial plan was to use a 5v 500mA buck module for the amp, not the 1A module. If I can get away with the former I could halve the size of the audio bus PCB as the 5v 500mA buck is tiny at 11 x 10.5mm. The mono amp only measures 6.5 x 12mm itself so the audio bus PCB would be very compact indeed.The only misgivings I have about using the smaller buck is there wouldn't be much current headroom. If my understanding is right, not enough current can also cause distortion problems and 500mA may be too close to the minimum requirements.

author: Canobi
author_rank: Regular Contributor
timestamp: June 02, 2015, 04:57:51 pm
content: I'm going to make two versions of the audio board, one for each buck and see what the difference between performances are. If I can get away with the 500mA buck, all the better.I put a diagram together, though I've left the LED charge status board out for now as I'm going to tinker with that one.

author: Zero999
author_rank: Super Contributor
timestamp: June 03, 2015, 08:24:39 am
content: Yes you're right, not enough current will cause distortion, since the voltage will sag during the peaks.Despite being more efficient, at full power, a class D amplifier will draw exactly the same kind of peak current as a class AB amplifier.Have you added any extra decoupling capacitors?If not then you may need to, in order to smooth the current peaks, just as long as the initial current surge doesn't cause any problems. Unfortunately you may need a large capacitor (1000µF or more) which even if you choose a 6.3V rating, takes up a fair amount of space.

author: Canobi
author_rank: Regular Contributor
timestamp: June 03, 2015, 08:50:45 pm
content: Quote from: Hero999 on June 03, 2015, 08:24:39 amSo reading between the lines of your comment it looks like there's a direct relationship with the current being drawn by, or provided to the amp and the volume of the sound being played back through it?Saying that I could adjust the sample volumes directly using my DAW to level out the waveforms to something more uniform and balance the volumes. That way they would produce predictable low level peaks at worst and a constant volume at best. I'd be loosing a lot of the transience to one or two sound doing that but it probably wouldn't matter too much anyway since the samples are going to be played through a rather small speaker.

author: rexxar
author_rank: Frequent Contributor
timestamp: June 04, 2015, 05:33:35 am
content: Quote from: Canobi on June 01, 2015, 08:53:28 pmYou may want to look into some C programming guides.Comments are noted in two ways:Code://comment out this lineorCode:/* everything between these two symbols is a commentincluding multiple lines */Comments are ignored by the compiler completely, they will never leave your .c or .ino file. (sometimes you'll see comments as /// or //* *//, the distinction between // and /// isn't important right now)In case you didn't already know, the compiler is a program that takes your "high-level" language (C), and turns the code into binary instructions that your microcontroller understands.The structure of function declaration/implementation is pretty easy once you get used to it. First, void. That could be void, bool, int, or any data type. What you put here tells the compiler that this function willreturna value. For example, you could have a function to average analog reads:Code:int voltAvg (){int someValue = 0;for (int i = 0; i < 2; ++i;){someValue += analogRead(pin);}return someValue / 2;}When you call voltAvg, you'd treat it like it was a number. You could assign it to a variable, or print it to the terminal. For example: Serial.Println(voltAvg()); will print the averaged value that voltAvg returns.If you define your function as avoidtype, that tells the compiler that the function isn't going to return a value. (programming is all about making the compiler happy)The parentheses in the function declaration tell the compiler that the function acceptsarguments. Let's say we want to tell voltAvg how many samples to average:Code:int voltAvg ( int sample ){int someValue = 0;for (int i = 0; i < sample; ++i;){someValue += analogRead(pin);}return someValue / sample;}Instead of averaging two samples, it will now average as many as you'd like. To print an average of ten samples you'd do: Serial.Println( voltAvg( 10 )); When you call the function, whatever value youpassto it in the parentheses (ten in this case) becomes a variable within the function. In this case, the variable is called sample, and during the function call it's assigned the value 10.There is technically not a limit to how much code you can put between the curly braces in a function, but it's good practice to separate different tasks into different functions. If there's an action you need to do a lot, it's much easier to just call a function than it is to write the same ten lines of code over and over. It will also make your program smaller, since those lines of code only need to be compiled once.Where in the file you put your functions isn't terribly important. If you put someFunction() in your .c file before the main() function, the program will still jump to main() first, because that's what it's been instructed to do.The program has a logical flow. At startup, it goes to setup(), and unless you have another function call inside setup, it will jump to main(). Once there, it will execute every instruction within the function in the order you write them. The program will only jump to another function when you tell it to. Your microcontroller is very stupid, you have to tell it exactly what you want it to do, step by step.There are a few things that are implicit here--you have no control over them. In the case of Arduino, the program will always start at setup(), and once it's executed all the instructions within that function, it then jumps to loop(). Once the program ends, it will go back to the first line in loop().One last thing about functions: You have to declare them, the same as you would a variable. So at the top of your file before setup(), you need to put "bool someFunction (int);". You're telling the compiler that somewhere later on there is a function called someFunction that will return a bool, and accepts an int as an argument.Check out this website:http://www.cplusplus.com/doc/tutorial/It's for C++, but the basics of the language are the same between C and C++.(I'm sure I've gotten something wrong, and one of the more knowledgeable people here will either correct or throw old scopes at me)

author: Canobi
author_rank: Regular Contributor
timestamp: June 04, 2015, 03:31:26 pm
content: Quote from: rexxar on June 04, 2015, 05:33:35 amThanks for the detailed explanation rexxar, some very handy info in there that will be mighty usefulI have some code for the accelerometer that I downloaded when I bought it and I also found code for interphasing with an SD card so hopefully that will cover the largest part of the coding. Just need to figure out how to shoehorn them in with the rest of the code when I get round to writing it.

author: Canobi
author_rank: Regular Contributor
timestamp: June 07, 2015, 05:38:15 pm
content: Been investigating the need for attenuating the audio signal and seem no further in finding a definitive answer, though I did find a few ways to achieve it so have some options just in case.Not exactly sure how to calculate the resistors for the "pads", though it sounds like I need to aim for around 2.5v +2.5v peak to peak (I think).Or, would something like this be OK (assuming R1/R2 and C1/C2 are correct)?Would take up less space than a pair of attenuation pads would.

author: Richard Crowley
author_rank: Super Contributor
timestamp: June 07, 2015, 05:47:45 pm
content: Why balanced? Unbalanced seems perfectly adequate and requires half the circuitry (and space).Why can't you control the output amplitude in software/firmware?

author: Canobi
author_rank: Regular Contributor
timestamp: June 07, 2015, 07:46:30 pm
content: Quote from: Richard Crowley on June 07, 2015, 05:47:45 pmLacking enough knowlege I'm a bit in the dark when it comes to attenuation, never dealt with it before. I could use some assistance with the audio side of things, there's me thinking it was going to be simpler using modules, just plug n playI asked whether volume could be coded myself in an earlier post, I'm sure it can be done but still looking for clarification on that one.Making sure the loudest parts of the samples are only 2dB to begin with would go a long way by the sound of it. I wouldn't have to worry too much then as any loud signals would still be under the max threshold.I won't be compressing/limiting the audio samples to even out the waveforms though as I found out that it would be very bad for the amp and speaker. By removing the dynamics there aren't any quiet parts and it doesn't leave them with any rest periods to cool down.

author: Canobi
author_rank: Regular Contributor
timestamp: June 12, 2015, 10:50:56 pm
content: So I've been investigating attenuation but still no clearer on the subject. I did however find out about resistor ladder DACs and shortly after, ladder DAC ICs.A promising looking one is the MAX550A. Still need to find a schematic for it and work out where I'm going to put it. Off the cuff I'm thinking on the audio board as it's 5v, though it'll work happily on 3v3 so I have some flexibility/options.On a side note, I'd been considering using the accelerometers two channels (L1 L2) as interrupt triggers but as I'm going for a DAC with only one output, and found out that playback just isn't going to work the way I originally thought (can't playback two sounds at once), I've had to rethink things a little.After managing a quick chat about my project with one of the IT guys at work, I learned that the accelerometer values can in fact be tied to the sample playback pitch/speed, so I now figure on using L1 to control most of the low to lower high Gs to create the sweeps with and use L2 with the highest Gs as an interrupt for triggering the impact sounds (which would take precedence over the hum during playback). The sabre would sound more natural and screen accurate that way too.Leaving out the sweep samples would give me much more storage space as there's quite a few of em. There's not much point in including them if I can replicate that effect with the accelerometer as they're only made up of the hum loop at verious pitches anyway.

author: Canobi
author_rank: Regular Contributor
timestamp: June 16, 2015, 08:18:32 pm
content: The 5v 3w mono amp breakouts I bought to go on the saber fx audio module arrived today. Free shipping and it only took 10 days to come from china, which is pretty damn quick to be fair.I didn't realise quite how small they really were. The dims were in the description but it didnt click. To give some referances for scale I've included a penny, the PCB is resting on the tip of my index finger.

author: Canobi
author_rank: Regular Contributor
timestamp: September 03, 2015, 11:47:46 am
content: Hi folks, I'm back (sort of)...Been awhile as other things are taking precedence at the moment (building a new workshop being one of them) but have managed to find some time to work a bit more on my project.I've been talking to one of the programmers at work about audio (it turns out he founded a company some years back called Leema Acoustic. I have a pair of their speakers and they are amazing) and he pointed me toward the WT588D-16p module and boy am I glad he did.After a look at the specs it seems to be a well thought out and handy bit of kit. I don't need to worry about attenuation for my amp board either as it has both PWM and "direct to DAC" outputs. It can also be controlled by 1 wire or 3 wire and is the same width as the pro mini but only 8 pins long so easily fits on my hub PCB and dramatically reduces the amount of satalite breakouts needed (now reduced to just the audio breakout).The other bonus is there are very few connections needed all round which makes everything so much simpler to work with. The new layout was a doddle so breadboarding should be too. The only part I need to fully concentrate on is the coding now.Talking of which:Does anyone know of a way (or if it's possible) to control the playback speed of a sample using code?I know playback speed has something to do with cycle frequency but I'd like to find out if I can tie playback speed to values generated by an accelerometer in order to bend a looped sound so it responds directly to the amount af force/speed being generated.

author: Canobi
author_rank: Regular Contributor
timestamp: October 04, 2015, 10:10:38 pm
content: Hi guysControlling the playback speed involes a PLL frequency synth chip so will save that idea for later.My board design is finally coming together and I ordered one of the WT588D-16p modules and a programmer to go with it so just waiting for those to arrive now. I also got some LP2992 3v3 regulators and FDN327N mosfets from RS which were the only items on my BOM list that were missing.I made this wiring diagram to show how it's all configured:I had a happy surprise when I checked for updates the other day and found one for the PCB design app I useThe update fixed a few annoying bugs and added some cool new stuff. As such, I gave the layout a complete redesign as I was able to consolidate everything onto one board.Note: I've attached a high res PDF of the layout as it was impossible to make a pic of it small enough to post that was still legible.I also made some changes to the PSU section as I wanted a way to disconnect the iC from the battery via some form of switch when not charging so made a short circuit between the two, which is a much simpler way of dealing with reverse voltage than adding more components to the same job.The only downfall in my whole plan is my total lack of coding skills and I'd be eternally grateful if someone could help me on that front.

author: Canobi
author_rank: Regular Contributor
timestamp: October 29, 2015, 01:36:23 am
content: Oops, sorry mods, I think I just hit the report button by mistake

author: Canobi
author_rank: Regular Contributor
timestamp: October 29, 2015, 11:54:44 am
content: I've attached new PDF which contains a schematic of the control section of the circuit, the diagram and the current PCB layout as it stands.I'm looking into making one tiny addition to the layout as I've just found a really neat and simple trick to give the blade LED a bit of random flicker, no PWM or 555 timers needed.The idea is to use a candle effect flicker LED and put it in series with the arduino and mosfet gate. The output of the flicker LED then controls the flow to the gate, which opens and closes in time with the flickering and thus passing the characteristics to the blade LED:If it works I'm going to assign a second LED pin as an fx free rail which I can switch between during instances when the flickering would not be beneficial:After looking a bit deeper into flicker LEDs and how they function, I found that I wasn't the first person to think of using them in this fashion and found this youtube vid showing it in prctice (minus MCU):http://youtu.be/753-lkao8l0The link on the channel takes you to a very interesting article about the inbuilt chips that control them and leaves a few uncharted paths of investigation which I think are well worth looking into further.But I digress, so to bring things back on topic I've made a pin designation list which I can refer to while I attempt to write the code:______Arduino Pro mini (5v 16Mhz)______A1: initiate LP2992 regulator to supply the 3v3 rail to the accelerometerA0: monitor WT588D busy lineSCL/SDA: talk to accelerometerSCK: clock reference for WT588DMOSI: data to WT588DSS (10): chip select for WT588D2: power button3: LED mosfet gate______________ WT588D-16p______________Vdd: main power pinVcc: module memory power (3v3)CLKMOSICSBUSYDAC_______________MMA84522Q_____________VccSCLSDANote: The breakout board has two shift register resitors for the SDA/SCL lines.One question springs to mind. Do I need to use the interrupts from the accelerometer to trigger sounds or can I just use the values it generates?So far I've worked out the easy part, how to assign the pin functions. Not a fantastic start, but its a start. Simple as it may be, the code looks like this:Code:int LEDPin = 3; // LED on pin 3int switchPin = 2; // momentary switch on 2, other side connected to groundint chip selectPin = 10; // WT588D chip selectint regulatorPin = A1; // regultor wake up pinint busyPin = A0; // WT588D busy lineconst int groundpin = 18; // analog input pin 4 -- groundconst int powerpin = 19; // analog input pin 5 -- voltageI'm going to tackle this one function at a time and for now I would be happy with just turning the LED on and off.After that I'd like to try and add a fade in at startup and fade out at shutdown which is why I wanted that extra LED pin I mentioned as it will allow for a clean fade effect and swopping pins in code looks a lot easier than heavy PWM crunching which my brain would struggle with.

author: Canobi
author_rank: Regular Contributor
timestamp: November 15, 2015, 12:00:17 pm
content: Oops, I misinterpreted the flicker schematic, so here is what it is supposed to look like: