Create sketch before circuit is created

I just completed a Pcb design and sent it to China to be etched. In the meantime, can I write the sketch and program the nano board before I have the pcb soldered and ready to use? Thanks

Yes.

You can write the sketch and program the Nano at any time. You do not need the PCB

Have you tested your project before committing to the PCB and if so, how ?

Sure, why not? People do this all the time. Heck, we write code without having even designed the circuit yet - sometimes you end up realizing as you're writing the code that the hardware design you had sketched out in your head wouldn't quite work...

Of course, you have to be prepared to "face the music" when you get the board and it turns out that something isn't how you thought it would be - but that's the life of an embedded developer!

Good software design, of course, becomes more important - pins as constants or #defines, rather than numeric literals in the code, for example, make it a lot easier to reconcile your code with the hardware.

Beyond all that though, it's generally a good idea to, before you have a board made, to have rigged up the circuit you plan to have made with breadboard and/or jumpers and done a sanity check sketch to make sure you can interact with all the devices the way you have them connected - which makes testing and development of the sketch while waiting for the PCBs easy, too.

Hi,
Have you constructed a prototype with protoboard?
PCB usually comes AFTER you have developed and tested the circuit as a prototype.

Tom... :slight_smile:

TomGeorge:
PCB usually comes AFTER you have developed and tested the circuit as a prototype.

Usually? :roll_eyes:

Usually, indeed.

Complex circuits I don't always test completely - complex as in having a big number of simple outputs, MOSFET switches or so. I know those simple bits work, it's then a matter of copying those parts and connecting to different pins of the port extender.

More complex bits of such a circuit I usually do breadboard, but not the whole thing.

Likewise for 220V AC circuits. Can't do that safely on a breadboard. Then I'd rather spend USD 11 or so for a set of small PCBs including shipping, wait a week (sometimes less) for them to arrive, solder it up, and hope for the best. No uncorrectable errors so far :slight_smile:

Paul__B:
Usually? :roll_eyes:

Heh, I definitely get boards made that I haven't prototyped - pretty frequently too :stuck_out_tongue:

Sometimes they even work!

And, jokes aside, sometimes you have to - if you're, say, making a DC-DC converter, for example, it can be hard to prototype it and have it work. Breadboards are kryptonite for layout-sensitive things like that. And on non-layout-sensitive stuff that I'm just too lazy to prototype, unless I really botched the design, problems can be patched up with a bit of cut+jump. I have a roll of that really thin wire that they use for that (at least in some circles, it's called E. C. O. wire, for Engineering Change Order - I don't know if that term is used outside of the specific company whose employees I've heard it from)

Thank all of you for your responses. These circuits are not my design, but copied from other circuits. I am using a tachometer circuit, an amperage sensor, and a voltage divider as a voltage sensor. These are pretty simple so I shouldn't have much of a problem. (I say simple, but there always is a chance of an error. )

In the meantime, can I write the sketch and program the nano board before I have the pcb soldered and ready to use?

I'm gong to say NO!

If you are a really good programmer and you have a simple program it can be done.* But since you're asking the question...

It's best to "develop" your code a little at a time, test-compiling and test-running as you progress. If you don't do that you can end-up with all kinds of bugs/errors that are very difficult to track down.

If you're a beginner, that means starting with something very simple that you know works (like the Blink Example, or another example related to what you're trying to do). Then add one or two lines of code at a time, testing as you go. That's not as easy as it sounds - You can't just start at the top and work-down... The compiler has to see a "complete program" that "makes sense" to the compiler.

With new "unknown" hardware it can be helpful to write some little test programs to make sure the hardware is working. (I always work on the input & output separately anyway.)

You might be able to write those in advance (or at least plan/outline them) but, you'll probably still have to debug once you get the hardware.

  • I was once forced to write a test program for something that didn't exist yet. (I'm not a programmer but I've done it for work a few times.) That was a long time ago and I don't remember how much debugging I had to do, but of course it didn't work perfectly the first time. I was able to "copy" from a similar program for similar hardware. (There was probably several hundred lines of code and maybe more than 1000 lines.)

I'm gong to say NO!

The horse has already bolted so it is too late to recommend best practices this time.

Maybe next time

Thank you for not flaming me for my question. I was planning to write my sketch and plug it into the nano to see if it will load without errors and correct the errors before the boards arrive. I am confident about the board design (aren’t we all) and I copied other sketches for my programming that seem to be OK. I should be set.

Hi,
If you already have the peripherals then you can start programming, BUT just separate code for the individual inputs and outputs.
If you have protoboard then start using it for each I/O module/device.

DON'T try and write your code for everything, ALL at once.

You need to get the different parts of your code working first before combining them, and realistically you can only combine them when you have the PCB to confirm each individual part first.

Tom.... :slight_smile: