New Controller Board

At least concerning the 3DOF hexapods we sell, the hardware came way before the software.

I can see at least one way to do this. For the same port, I can just shift a bit and write to the port. I modified the program to take out all the stuff except for PORTD. I moved my LED to RD0 and am just toggling that bit instead of all the ports. I’m preparing for other tinkering. :smiley:

Yes, I am. The Student edition compilers - C18 and C30. The price is right for me. :slight_smile:

Apparently some of them do, but the '877A is not one of them. I wanted to tinker right away, and there is a project I want to do with the 2550/4550, and Grasshoppah is helping me get up to speed with it.

I go to Norvac Electronics here in Beaverton. So far, they have had everything I need, and way more.

Well, Olimex sure seems to have done there job and I am quite happy with my decision to purchase this ICD2.

8-Dale

Then we should figure out a header file to take care of the pin macros. RA.3, RB.0 PORTA, stuff like that I think are different between compilers.

What code of Pete are you compiling?

Alan KM6VV

These have pretty much already been done, but I don’t really care for the long names Microchip has used. I would prefer to use something like PORTD.RD0 instead of PORTDbits.RD0 but I’d only save 4 characters to go with the shorter names.

One thing I did for my Renesas H8/36077 starter kit is I added all the signal name aliases for each pin. So I can call out SDA and SCL without worrying what port or pin number they are. I think this sort of thing makes code much easier to understand.

What do you think about this?

Just his stock code. I figured out why I could not build the code for the 4620 - when I separated the two code sets into separate folders, I did not get something copied to the 4620 folder. I don’t know which file that is at present. I just like to have code separated when it is clearly for different purposes (18F4620 and dsPIC4011 in this case).

I redownloaded Pete’s code and extracted it with his directory structure which I will leave as is for now.

I have also been thinking about connectors. One more way to save board space is to use a header for the standard serial port(s) and use a cable from that to a standard DB9 connector. That DB9 takes up quite a bit of space I can think of better uses for. :smiley:

8-Dale

I don’t like the long names either. the Hi-Tech header gives me considerably shorter names. RA2, RB1, RC0, RD4, RE1 are about as short as you can get!

I just got my Renesas board! Brought it home today. I think there was a limited time compiler in the kit. Have you tried it? I didn’t want to activate it yet.

Yes, I use the signal names when ever possible. And then I map the “leftover” pins that I use with readable names. This is a two-layer process.

#define SPI_DAT  RB0    /* DualShock SPI DEFINES  */
#define SPI_CMD  RB1    
#define SPI_SEL  RB2	 
#define SPI_CLK  RB3	
#define DEBUG1	RB6	
#define DEBUG2	RB7	

These are samples of Hi-Tech’s mappings:

/* Definitions for PORTB register */ static volatile near bit RB0 @ ((unsigned)&PORTB*8)+0; static volatile near bit RB1 @ ((unsigned)&PORTB*8)+1; static volatile near bit RB2 @ ((unsigned)&PORTB*8)+2;
They are derived from this:

static volatile near unsigned char PORTB @ 0xF81;
a PIC.H file takes the processor type, and loads the needed header:

PIC18F4550.H

This construct then gets headers for EITHER 16F or 18F parts:

#ifdef _PIC18 #include <pic18.h> #else #include <pic.h> #endif
I think you’ll get the set if you download the free compiler, or I can send you one.

I have it in a directory or two, but I haven’t tried to compile.

That’s true. You can also get a “dongle” with 1 or 2 RS-232 converters and connectors. I use it on the board I designed for work work. We don’t ship the board with RS-232 (just RS-485, but it’s useful for debug. When the robot is static and you want RS-232, you use the dongle. When the robot is disconnected, you don’t need the dongle. Less weight and space on the board!

Alan KM6VV

Now that I have done this for the Renesas starter kit, I can do the same for the PICs. It’s pretty easy to make a new .h file that loads the standard one and creates new names for things. I’ll work on one.

Did you get the H8/36077 kit? I have that and the H8SX/1664 kit, but I will have to install the header pins for the MCU signals myself.

That’s a nice setup - automatically getting the right header file for the MCU type.

Yes indeed, the more weight you can leave off, the more you can load on the robot. :smiley: I had to convert WALTER to run using motors because he got to heavy for the continuous rotation servos.

Oh, by the way, Alan, I did accept your challenge to create an LED sequencing program and just finished it. :smiley: The only port that has all 8 bits is PORTB, which also has PGC and PGD ICSP signals. I have to disconnect PGC and PGD to run the circuit or the most significant 2 LEDs won’t work.

8-Dale

I’m thinking we could even run the 'bot code on the Renesas board, in addition to the PIC, AVR an ARM7 options. Pick one, or more! I got the H8SX/1664 kit, but I haven’t had much time to look at it. The board’s about the right size! and there’s an ICE module or something with it. What are the MCU pins? Just .024" square pins?

All my other 'bots are BIG. In fact, the biggest had an XT motherboard for a computer! I initially tested the motor drive platform by sitting on it and going for a ride! But it can’t climb stairs, so it sits in my upstairs office… for now.

Good! You got it working. Tonight I borrowed a BASIC STAMP 2 from my robot friend, and wrote a little program to flash an LED just as you’ve done. I’ve got the 'bot back, but the batteries were dead. this weekend I hope to get it connected up to the 4620 Quick Flash board, and see if anything is working. I loaded up the PS2 test, but didn’t have time to get the PS2 wired up. I intend to also try the Atom code for the Stamp 2, for comparison.

Alan KM6VV

Yes, I know. :smiley: I got this vision of a main controller using several PICs to do various things. Right now, I really want to concentrate on a dual MCU board like Pete made. I checked the cost of having some of his boards made by ExpressPCB and it is about $55.00 for two and $85.00 for four. It’s not too bad really, and I’d want at least two boards anyway.

I am sure they are just .1" spaced standard pins like those used on the mini-ABB.

Yes, I did and it came together real fast.

Here is my current code for ledseq:

[code]/*
Program: LEDSeq - Sequences 8 LEDs
*/
#include <p18f4550.h> // Device dependent interrupt definitions

#define ICD_DEBUG //Enable the ICD

#pragma config WDT = OFF, FOSC = INTOSCIO_EC, LVP = OFF

void delay_ms (int x);

void main()
{
int i, j, bvalue;

// Initialization
OSCCON = 0x70;      	// 8 Mhz

PORTB = 0;
TRISB = 0;				//0 = Output, 1 = Input

TRISDbits.TRISD0 = 0;	//0 = Output, 1 = Input

// Flash all LEDs to show they are working
PORTB = 0xFF;
delay_ms (100);
PORTB = 0;

while(1)
{
	PORTB = 0;

	// Flash the heartbeat LED each cycle
	PORTDbits.RD0 = 1;
    delay_ms(25);

	PORTDbits.RD0 = 0;
    delay_ms(100);

	// Cycle the 8 LEDs
	bvalue = 1;

	for ( i = 0; i < 8; i++ ) {
		PORTB = bvalue;

		delay_ms (100);

		bvalue = 2;

		// Shift to the next bit
		for ( j = 0; j < i; j++ )
			bvalue = bvalue * 2;
	}
}

}

//General short delay - this is not a real ms delay (yet)
void delay_ms(int x)
{
int x1, y, z;
for ( x1 = 0 ; x1 < x ; x1++)
for ( y = 0 ; y < 4 ; y++)
for ( z = 0 ; z < 176 ; z++);
} [/code]
I have also created a new project and have brought a few files from Pete’s work over to it - the I2C stuff. :smiley: I also have two MCP23017’s on the breadboard ready to be wired up.

8-Dale

         bvalue = 2;

         // Shift to the next bit
         for ( j = 0; j < i; j++ )
            bvalue = bvalue * 2; 

First thing you can do to improve that is use

            bvalue *= 2;

Did you actually know what your doing is raising it by the power of 2? In the math.h library there is a pow(); function :wink:

Another method of doing this is simply bit shifting. Simply start with 0b0000.0001 and shift by 1 to the left every time. Another way is to make a 1 x 8 array and mask the bits :slight_smile:

I would suggest the bit shifting method as its much faster than using pow or a for loop. One of the most simplest operations on a micro.

-robodude666

Yes, I know. :smiley: I did this late last night and just wanted to get something to work. The code I wrote was the first that came to mind. It’s more or less brute force, but it does work as I want it to work. :slight_smile:

Yes. I thought of the shift method, but just didn’t get around to implementing it. I am one of those who has to have everything I am working on finished before I can do anything else, including go to bed.

8-Dale

Here is a slightly improved 8 LED cycler:

[code] // Cycle the 8 LEDs
bvalue = 1;

	for ( i = 0; i < 8; i++ ) {
		PORTB = bvalue;

		delay_ms (100);

		// Shift to the next bit
		bvalue = bvalue * 2;
	}[/code]

I did not need the inner for loop at all, and don’t know what I was thinking when I put it in. This executes faster and the overall code size of the program is smaller.

8-Dale

Here is an example of what I have in mind for the stacking connectors. The only difference is they would be pins and would be on the bottom of the board instead the top for the main MCU board. Other boards could have the sockets on the top and/or pins on the bottom. There has to be clearance to plug sensors and/or servos into the board at the top.

http://www.modtronix.com/images/sbc65ecr1.jpg
I think Modtronix has the right idea for stacking.

Another good example set is:

Main MCU board could be done like this:
http://www.newmicros.com/store/product_pictures/Pluga2138_DP.jpg

Other boards could be done like this:
http://www.newmicros.com/store/product_pictures/XB_Pluga_232_DP.jpg
I think New Micros does it right also. :smiley:

8-Dale

Hi Dale,

Pick one, or more!

Not too bad. ExpressPCB? Then there won’t be Gerbers. Too bad. I’d consider re-drawing in Eagle, so that I can create Gerbers and also isolation “Gcode”. Might want a change or to anyway; I haven’t studied the board. I would be interested in milling it on my CNC’d Sherline mill.

Oh, I think I can find a few of those pins. Have you heard of Scmartboards?

schmartboard.com/

They have some jumpers that are made for .025" wrap posts. I cut off one end and crimped on a removable pin for a female DB connector, and now I can easily “patch in” the PS2 connector (no bulky cable needed). Good for regular interconnects as well.

Yes, I did and it came together real fast.

I have also created a new project and have brought a few files from Pete’s work over to it - the I2C stuff. :smiley: I also have two MCP23017’s on the breadboard ready to be wired up.

8-Dale

Your code looks fine! There are MANY ways to do a loop and shift bits. One of my favorites is:

/* Shift to the next bit */
for(bvalue = 2, j = 0; j < i; j++, bvalue <<= 1);

There’s ALWAYS another way to do something!

The stacking connectors look good. We have a long pin connector that gives about .75" that might be useful. But then it gets a little harder to get inside and probe signals. I wouldn’t mind some sort of HINGED connector, so that the stack could be fanned opened up like pages of a book on one edge. Anything’s good at this point. The jumpers I mentioned could be useful (shortest). We might also consider ribbon cables w/ IDC connectors. Mother boards? This project is starting to sound like work work (actual work done at a person’s place of employment).

Alan KM6VV

ExpressPCB is just what Pete used to make his boards. It’s not mandatory to use them for anything else though. It would be cool to have the schematics in Eagle. I still haven’t spent any time learning Eagle, since I am more interested in the software and design aspects of projects. I’m getting to where I would like to be able to create schematics for my circuits though, and Eagle seems to be the most reasonable/affordable package for this.

Yes, I sure have heard of them. :smiley: I’ve been tempted to try out some of their modules. There are some MCUs I would love to try working with, but most of them are in 64, 80, or 100 pin QFN packages.

I will have to look into these then. I am for anything that makes connecting to pins and such easier. :smiley:

I want to stay as simple as possible with the stacking arrangement. The main thing is to cut down on cables that would otherwise be needed between boards. Any stacked boards that might need connection to offboard stuff can be done with right angle connectors.

This is always a possibility. It should be as easy as possible to make any needed connections.

This is supposed to be fun and interesting to do and something that will be useful for us as well as others. :smiley: I wish I could do more of the schematic and PCB stuff. Design and software is my main focus though, and I do hardware only when I need to so I can do the software. :slight_smile:

8-Dale

Hi Dale,

I learned it, but it is still confusing to add a component. BUT, it gets me CNC files I can use to mill boards. And one could always send out the Gerbers as well.

They work good; I’ve used them for Atmel ARM7 and USB processors, and a lot of little chips.

I can do a little Eagle, and I’m getting into Altium at work. Really no time to lay out a board! Board layout becomes a project in its self which winds up competing for my attention (I oversee the layout, 'tho). I can only concentrate on so much at one time!

I’d rather be designing the circuitry, and programming. Even that tends to be too much at one time… especially with all the engineering paperwork needed to go into production. This last time I had to learn a new processor (ARM7), compiler (IAR), sift through 15 year old legacy products to deduce function and operation, and put up with the sales department requests.

The Open Servo guys are using Eagle for schematics and board layout also. OK, I have this circuit on my breadboard with 4620 (switched out the 4550 to program Pete’s code), 9 LEDs and resistors. I guess it is as good a time as any to see if I can get this into Eagle. :smiley: I find it very difficult to find parts I want to use, particularly connectors.

I would love to try out some easier to use schematic capture and board layout software, but most companies do not offer trial or low cost versions. :frowning: I wouldn’t even have 3D CAD software if it were not for Alibre and their 12 month payment plan (no financing, just divide price by 12 months). I just made my last payment!

I love doing this stuff, but then, I don’t have to answer to anyone but myself and don’t have bosses looking over my shoulder. I can take my time and work on it when I feel like it. :slight_smile:

8-Dale

Hey, Alan and everyone,

I’ve been doing a bunch of thinking about this project and am wondering a few things…

  1. How hard would it be to just add the 3 pin headers to Pete’s existing design?

  2. Ditto for stacking connectors?

It looks like it would not be too difficult to substitute an 18F4550 for the 4620, both hardware and software. I like really like the idea of having a board that can speak USB (host and client). This would also allow the board to be used as an I/O processing subsystem from Linux or Windows and it could be programmed to speak to the host via USB, I2C, or SPI/standard RS-232. I’m going to check the schematic and see if there are any major hardware changes that would have to be made to accomodate the 4550, other than providing for a USB connection. I’m going to see if I can get Pete’s 4620 code to compile for the 4550.

I’ve looked at Pete’s stuff when he was first working on this, and his design is really good. I don’t really want to mess too much with something that is already good and works. As far as I am concerned, Pete’s design already has what I would like as far as power and I/O features. His hardware is already good, and software can be changed easily. :smiley:

The 4620 and 4011 chips could even both be programmed to be slaves to a more powerful MCU. It all depends on the particular application.

I was also looking at the Modtronix boards again - I keep coming back to these for some reason. They already have the stacking connectors in place, but they don’t have the nice 3 pin headers that makes it so easy to connect stuff for hobby robotics.

Getting back to Pete’s design, I think it would be a great platform to build on with the addition of 3 pin connection headers and stacking headers. I am really coming to appreciate Pete’s design more as I get deeper into looking at what he has done. I was excited about the dual MCU design when he first started talking about it.

What do you think?

8-Dale

That’s not too bad. I’ve just ordered 3 Quick Flash boards, so I’ll see about doubling up with them. Let me know when you get your boards talking! In fact, as I2C is addressable, I should be able to get all 4 of my boards to talk to each other!

Was there something special you were going to do with the 23017 parts? Part of a plan? You can use them to drive 8 servos each, much like the SSC32 does. I used the shift registers to shift in triggers, and shift out relay drive bits on one project. Also handled as inputs by shift registers are 5 push buttons, 4 jumpers, and 3 LEDs.

I see you’ve been working on your program!

Alan KM6VV

Hi Dale, all,

Probably not hard to add parts, but would require layout changes! I’d have to look at Pete’s design more for any other comments.

Watch out for the USB pins, I think they moved tx/rx to make room for them. So not DIRECTLY pin-compatable. Also, the 4550 is only a “device”, not a host. Still good! only half the memory of a 4620, but good. One of the reasons I was first looking at the PICDEM FS USB board for a 'bot board.

Oh that’s right, only one master, several slaves. Probably makes sense. I had taken a brief look at the I2C code in each, and I half expected the code to be almost identical, just a “flip” between master and slave modes. Maybe there’s more to it! I do mostly SPI, which doesn’t typically have addressing. What was the bandwidth limitation?

Modtronix stacks nice. But it really takes some effort to get a detailed set of boards to stack properly. And then it gets hard to add new features. All boards the same? Should have some variety of features as well.

So when will you have the Eagle files ready?

Alan KM6VV

Oh, I know there would have to be PCB layout changes to deal with the additional connectors. I’m just trying to find the easiest route to get a bot board type of board without changing too much of Pete’s design.

I have been looking at Pete’s schematic and have only found two conflicts so far that would require circuit changes to allow using a 4550 instead of a 4620. Can not use RC4 and RC5 (Heartbeat LED) because these are the USB data lines of the 4550. Move the HEARTBEAT LED from RC5 to RD4. Can not use RB0 (PIC to PIC Interrupt) and RB1 because these are SDA and SCL (I2C) on the 4550. Move the interrupt from RB0 (INT0) to RB2 (INT2). The software changes should not be too difficult. I think the only other circuit changes are just changing the pins to match the 4550, because it looks like the 4550 has all the other peripherals the 4620 has.

Well, there is actually a multi-master specification as part of the I2C specification created by Philips, but I hear it would be a real bear to implement. I’m happy with just having master/slave though. Microchip claims up to 1 MHz for I2C, but 400 KHz is probably a lot more reasonable based on what the Open Servo guys are doing.

Modtronix has many different boards, both PIC microcontroller boards and peripheral boards. If stacking is going to be a problem, maybe an alternative would be a ribbon cable going between boards, but this would probably make connecting more than two boards difficult at best. I’m not sure this would be a problem in most cases though.

I’ve been resisting learning Eagle, but maybe I should just bite the bullet and jump in. :smiley:

8-Dale