The blog of a dedicated radio amateur and electronics enthusiast

"Having fun on the air and in the workshop - communicating and creating"
Showing posts with label Microchip. Show all posts
Showing posts with label Microchip. Show all posts

02 November 2012

PC-to-PIC serial comms


I have been programming the EUSART module of a Microchip PIC18F4550 microcontroller on my MYDEV2 development board for RS-232 serial  communications with a pc running a terminal application; in my case 'HyperTerminal'. I have configured the connection for 1200 baud asynchronous operation. Although this is one of the slowest of the standard com port baud rates, however in conjunction with the 8MHz PIC clock it gives the lowest baud rate error of only 0.1%.
The connection is called PC-PIC_EUSART. Pressing any key 'wakes up' the EUSART and starts the sequence. The above capture of the Hyperterminal screen shows, for example, the steps taken to change the dfcw dot-dash frequency shift to 4Hz. All seems to be error-free !
Now that I have the connection working, I am considering incorporating serial comms functionality into my PIC controlled frequency synthesiser, so that values, e.g., relating to priority band and dfcw shift, which are held in PIC data eeprom, can be changed quickly in real time without having to modify, build and reload the entire source code file.

28 January 2012

Gradually moving forward

Having a lot of spare time recently has enabled me to progress with some unfinished PIC MCU related activities. For the first time I have been writing code in 'C' language and programming PIC MCUs using Microchip's MPLABX IDE and ICD3. So far I can write characters to a display, and also detect when any button on a particular row of a keypad has been pushed; all quite encouraging. But I still have much more programming to do in order to complete even the quite basic operation of keying-in and displaying numerical data.
I have also been experimenting with software, ( assembly language in this case ), to detect disconnecting the power source from a PIC microcontroller, ( PIC18LF4455 ). A variable low voltage power supply would be very useful here.
And finally, from a most unexpected source, I have obtained cut and engraved black plexi front and rear panels for the frequency synthesiser enclosure.

14 September 2011

MyDev2 enhanced

Schematic - note Vcc connection depends on usb-powered or self-powered application
I have upgraded to version 3 my PIC MCU development platform, MyDev2, ( first posted on November 2nd, 2010 ), with the addition of pull-down resistors R25-R28 for the keypad rows connections now that I have decided on the method I will use in coding the operation of the keypad and the interfacing required to the microcontroller. I have already started writing the code in 'C' programming language, instead of the 'Assembly' language which I have used for all my PIC projects until now. The keypad will be a 'telephone' style 4 row x 3 column, 0-9, # and * type.
I have also fitted a new microcontroller type, Microchip part PIC18LF4455-I/P, which, as well as being a few cents cheaper than the original PIC18F4550 and PIC18F4685, has an extended operating voltage range, ( denoted by the 'L' in the part number ), down to +2V, as I want to experiment with coding the detection of switching off the power !

12 July 2011

Then there were four

From time to time since the last post, ( 16 June ), I have been populating three more circuit boards; four are now complete. This is not quite the rate of 3 per week which should be achievable, single-handed; what an efficient production line that would be !
During this activity my soldering skills working with surface mount components, some minute, have quickly improved. Surprisingly, I didn't find the 44 pin microcontroller chip to be the most difficult to mount.
Now I will progress further with the case. I have already finished the technical drawings for the top, base, front and rear panels ready for their fabrication. And today a local firm precisely cut the extruded, anodised aluminium sides to the final length.

08 March 2011

The art of pcb design

 
Coincidentally, the rotary encoders and Microchip microcontrollers for the current version of the frequency synthesiser project both came in the post today; one of each is required in each synthesiser. I had been waiting especially for the arrival of the encoders as I had to create that part in a new component library inside the CAD software so that I could complete the artwork for the track layout of the double-sided printed circuit board.
Microchip had protected the microcontrollers in a little plastic box, ( like a presentation box for jewellery, rings etc), lined with static dissipative foam. I must say that this level of care impressed me ! A pity, though, that both chips flew out when I opened the box for the first time.
An encoder and microcontroller will be in the positions of SW1 and IC1 respectively. For clarity, just for this posting, the picture of the pcb design, ( actual size 4.0" x 3.2" ), doesn't show the copper-fill for the ground-plane on the topside. I have made pcb's many times in the past for various projects; but this one will have to be manufactured commercially.
The encoder is an Alps part, type EC11B152420Q, ( having 30 positions and 15 pulses per revolution plus switch ), and the Microchip microcontroller is type 18F4550-I/PT, in a 44 pin thin quad flatpack (TQFP) plastic package.

10 February 2011

Bootloader in action


After programming a boot-vector and boot-block into the PIC microcontroller's flash program memory, I used a bootloader to upload my application code to the PIC from the PC using its com port, the level converter, ( featured yesterday ), and the EUSART, ( enhanced universal synchronous asynchronous receiver transmitter ), connections on the PIC. The top picture shows all the project hardware, looking a bit untidy by now.
To check, I read back from the PIC to the bootloader the entire contents of program memory, ( actually also data eeprom and config ). The screen capture in the lower picture shows just the first portion of this, from address 0000hex to address 00DFhex. On looking at this I can see that the bootloader has highlighted the boot-vector code, at address 0000hex - 0003hex; the high priority interrupt vector and low priority interrupt vector are still at 0008hex - 000Bhex, and 0018hex - 001Bhex respectively. My PIC type, com port and speed are correctly declared in the bottom right corner. I notice that the time taken for the flash memory 'read' was 35 seconds. I'll configure com2 for a higher speed to reduce this, although I won't be reading memory very often. I recall that, earlier, 'writing' took only 4 seconds.(*)
It'll be interesting to use the bootloader for programming instead of the ICD2, which of course will still be essential for debugging.
All this has got me thinking about the download area on my eventual (?) website !
( My thanks to Microchip Technology Inc. for the freeware serial bootloader AN1310v1.04 )

* Update, 11 February : I subsequently changed the speed of com2 from 9600 to 115200 bits per second; now write and read times have been reduced to 0.942 and 2.975 seconds respectively.

30 December 2010

DDS deadline met


I have completed the first prototype of the dual-band frequency synthesiser, ( just before my self imposed deadline of the end of the decade ), by writing the last piece of the software to tune the output frequency up and down in 1Hz or 10Hz steps. This function works perfectly; whatever the actual output frequency, it precisely matches the frequency indicated on the display, as of course it should do. So 2010 will end on that happy note. But what about the future ?
This first prototype is what I would consider as a ' concept and technology demonstrator'. For the second prototype synthesiser I have decided to change to a more sophisticated PIC microcontroller, and one that has not been in production all that long, e.g., the Microchip PIC18F4550, which will allow me to implement more features. In fact I have already completed about 25% of this prototype , based on "MyDev2"; see posting on 2nd November.
Concerning software, until now I have been programming in Microchip's assembler language. Using 'C' language is probably a better choice in future. I have absolutely no prior experience of 'C'; but what I do know is that its command syntax is more descriptive than assembler, and the code is not type specific to any one manufacturer's microprocessor families. Some of the extended functionality I want for the second prototype is better suited to 'C' and would be extremely difficult to program in assembler for a novice programmer as myself. The PIC18F4550 can be programmed in both assembler and 'C'.
Back to the present, and the first prototype is shown in the upper picture placed on top of my longwave transmitter with which it will be used to gain some operational experience which may suggest improvements or further development. The middle picture is the post-filter rf output voltage displayed on an oscilloscope, showing a 656mV peak-peak pure sine wave. The lower picture is the output frequency of the synthesiser as I tune it from 137700Hz +/- 50Hz in 10Hz steps.

02 November 2010

MyDev2 replaces MyDev1

PIC18F4550 version
PIC18F4685 version
Schematic - note Vcc connection depends on usb-powered or self-powered application
Development boards for microcontrollers are essential for debugging code and checking hardware peripherals before committing to the final build-configuration.My first microcontroller development board, which I called "MyDev1", has served me quite well; see 25th January. It is a typical, solderless, experimenting board; component leads are a push-fit into the holes. Its limitations, however, began to become apparent; noisy, intermittent connections, lack of flexibility and a real nightmare if I had ever attempted to use it with 40 or even 28 pin microcontrollers and interfacing with several hardware peripherals at once. Having unreliable connections is a really bad situation when the microcontroller is waiting, or looking, for changes.It was therefore time to upgrade to a better system; so I have produced "MyDev2". Now it is much easier to reconfigure for different peripherals, e.g. display, keypad, rotary encoder, comms ports, and to check their operation. Of course, I haven't omitted the LEDs, and "MyDev2" has many, ( different colours for different ports ), as it is always nice to see pretty lights as a visual indication of I/O port output state ! I could not avoid solderless connections entirely; but those are of a high reliability using good quality pin-headers.
"MyDev2" connects to the Microchip ICD2, ( In-Circuit Debugger No.2 ), for programming and debugging operations, thereby replacing my original home-made programmer, ( see 25th Jan, 8:06PM, purple box ).
Using a development board I was easily able to change between two mechanical rotary shaft encoders, ( control with knob ), from different manufacturers, choose the more appropriate one for my final application, and 'fine-tune' the PIC code to suit.
Incidentally, the microcontrollers featured in the pictures above are 40 pin Microchip parts, ( lower ) type PIC18F4685-E/P, and ( upper ) type PIC18F4550-I/P which incorporates a USB interface.

25 January 2010

New design in progress


This is my current project which is still at the very early stages of development. I am hoping that eventually it will become a frequency synthesiser. For the first time I am using a programmable integrated circuit, PIC, which is basically a microprocessor using a reduced instruction set of around 40 commands. I am writing and testing the source code, burning the PIC, rewriting and retesting etc. Keep a look-out for future progress reports.