Arduino controlled wheelchair

Power wheelchair board for REAL info!

POWERCHAIR MENU! www.wheelchairdriver.com/powerchair-stuff.htm

Re: Arduino controlled wheelchair

Postby LROBBINS » 06 Nov 2015, 00:11

A CAN transceiver will normally only transmit if there are at least TWO CAN nodes, not one node and a logic analyzer. With only one node, the sending node doesn't receive an ack and will go off-line in short order. Once you have two nodes talking to each other, you can see the CAN frames with some logic analyzers - but remember, this is a differential serial and not all analyzers are set up to interpret this. PM me an e-mail address and I'll send you the CAN library and a couple sketches that let one test the transmit/receive process. I use this rather than a logic analyzer or CAN sniffer because I know what messages I'm wanting to send and receive, not trying to hack someone else's higher level protocol
Ciao,
Lenny
LROBBINS
 
Posts: 5789
Joined: 27 Aug 2010, 09:36
Location: Siena, Italy

Re: Arduino controlled wheelchair

Postby gcebiker » 08 Nov 2015, 04:51

Hi Lenny, got two hooked up (Leonardo CAN BUS boards) and talking to each other.
I'm able to 'see' the data transmitted via the serial monitor on the RX board.

Turns out my Logic4 is not able to read such low voltage signals https://www.saleae.com/#DatasheetTile

Ive either got to get a Logic8 or up the power...or just read it with the serial monitor on the receiving CAN BUS board.
(i still may be barking up the wrong tree but its fun all the same.)

I think ill be upgrading the Logic4 to the 8 as i was going to do a few weeks ago so i can read the timing on the data packets.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby LROBBINS » 08 Nov 2015, 09:04

I don't think that you are going to be able to mimic the Shark's serial signal using CAN boards because the CAN controller will only send and receive CAN packets. That is, you send an ID and data bytes from the Arduino MCU to the CAN controller by SPI, the controller then adds all the stuff needed to make it into a proper CAN packet - bit timing, CRC field, frame start and stop bits etc, and sends that to the transceiver as ordinary tx rx. The transceiver has the simple task of voltage shifting tx rx into the differential CAN-H and CAN-L outputs and transforming incoming CAN data back to tx rx. The controller keeps sending the outgoing message while for an ack, and at the same time buffers incoming packets and extracts ID and data bytes to send them on to the MCU. You're not going to be able to construct, send or receive anything other than CAN packets.

A simpler task might be to tap into the lines from the Shark's joystick itself. Unlike the DX which uses an analog joystick, I think that the Shark has an SPI output joystick. That's a fairly simple protocol that shouldn't be hard to hack, and all the hardware for communicating by ISP is already in the Arduino. You'd just have to inject your information coming from whatever source (bluetooth, RC transmitter etc.) into those pins and the chair would think it's seeing a joystick. Doesn't give you control over anything else, but it would give you joystick input. Rather the same as what Woody has done for P&G controllers, except that it would be SPI rather than analog.

Ciao,
Lenny
LROBBINS
 
Posts: 5789
Joined: 27 Aug 2010, 09:36
Location: Siena, Italy

Re: Arduino controlled wheelchair

Postby gcebiker » 08 Nov 2015, 10:11

Yes i have to agree Lenny.

With out knowing anything about CAN, i bought the Leonardo CAN BUS Arduino's

...maybe all i needed was the MCP2551 chip, to get the
differential H/L
signal i was seeking.
In my googling about i had searched, mirror signal, opposite signal, inverted signal but never Differential ! i am a dummy, ive see the reference but never joined the dots.

Or maybe there is a better chip out there for getting the differential High/Low signal ?

I received one of Woody's Bluetooth/Smartphone controlled interfaces on Friday, along with some extra cabling/plugs.

The plan has always been to do as you suggested..and hack the bus (if i CAN..pardon the pun), well its differential serial Async after all.
And hack the joystick inputs.(JC2000 in my Qlogic controller and the JC2000 in my folding chair)

Mainly its that the shark i sit in as i write this is not so hacker friendly as the JC2000, as the DX Shark is a integrated circuit board joy.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 08 Nov 2015, 14:28

Ordered a few MCP2551 boards.

Data sheets and examples over on GitHub seem to indicate to my tiny banana loving brain that it might work (reads - hairy ape man finds fire..)

http://www.superdroidrobots.com/shop/it ... kout/1841/
https://github.com/SuperDroidRobots/CAN ... TE-242-001

http://www.ebay.com.au/itm/MCP2551-High ... SwMmBV6pdL

Terminology is really confusing, everywhere its referred to as a CAN transceiver, nowhere as 'differential signal transceiver/generator'.

Been reading a lot of CAN's tonight, i hope i CAN, i hope i CAN. Its the little wheelchair that could reborn :mrgreen:
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 22 Nov 2015, 03:19

I connect and disconnect the Arduino's i have been using, the usb connector is not holding up.

I am going to try to learn the http://nodemcu.com/index_en.html , hopefully it will mean ill be able to tweak the emulator wirelessly.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby LROBBINS » 22 Nov 2015, 03:38

First thing I do with a new Nano or similar is to run a bead of Goop around the mini USB connectors, including the bent metal spring fingers (careful to not get it inside). The springy rubber keeps the metal from distorting, so the plugs keep holding through multiple ins and outs. Ciao, Lenny
LROBBINS
 
Posts: 5789
Joined: 27 Aug 2010, 09:36
Location: Siena, Italy

Re: Arduino controlled wheelchair

Postby ex-Gooserider » 24 Nov 2015, 02:51

The other thing that is worth considering is to make 'pig tails' to use with boards on test bed duty, then do the plug / unplug thing on the relatively expendable pigtail...

Years back I worked on systems where we had a bunch of PC clone boards in a rack and were constantly plugging and unplugging a VGA monitor to different boards as part of the programming and test process... Sooner or later the male plug on the VGA plug would get mangled - leaving either the need to get a new cable (or was often the case with the cheap monitors we were using, replace the monitor because of the non-detachable cable.... I found a source of 'pass through' connectors that were essentially 'gender-changer plugs' that didn't change gender... Screw them onto the end of the cable and we were working with the connector instead of the cable connector - Cost was about $2.00 each, and so was a lot cheaper to toss a mangled connector than a monitor....

ex-Gooserider
T-5, ASIA-B
Jazzy 1100
Jazzy Select 6
Quickie Q-7
Invacare Mariner
Want to make / get a better chair, ideally one that stands.
User avatar
ex-Gooserider
 
Posts: 6228
Joined: 15 Feb 2011, 06:17
Location: Billerica, MA. USA

Re: Arduino controlled wheelchair

Postby gcebiker » 28 Nov 2015, 13:54

Got the MPC2551's in the mail (breakout boards)
no success as yet getting them to transmit the data from Arduino.

Quite possibly they will not run from a USB port and need external power (higher current) to Arduino...
Not sure yet.

Development board might have a fried 7805 regulator chip from a bit of a brief magic white smoke incident...
...I'm still not sure where the smoke came from


I'm considering getting a better magnifying glass and reading the chips the original joy uses.
I'd not done this earlier as they all seemed to be cleaned of any markings.

Anyone ever seen what other chips the Dynamic Shark Joystick has on the PCB ?
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby LROBBINS » 28 Nov 2015, 19:44

Quite possibly they will not run from a USB port and need external power (higher current) to Arduino...

No, USB to the Arduino is quite sufficient to run both a MCP2515 and 2551. The 2551 won't do squat however unless it's hooked to a 2515 (or some other source of tx and rx meeting its requirements - see the data sheet.) Also see the data sheet for what state the other pins on the 2551 need to be in to make it active. I guess that a 2551 alone could convert non-CAN formatted tx/rx into differential CAN voltages. Do you know if anyone has ever done that?
LROBBINS
 
Posts: 5789
Joined: 27 Aug 2010, 09:36
Location: Siena, Italy

Re: Arduino controlled wheelchair

Postby gcebiker » 29 Nov 2015, 01:35

I have not found anyone publishing their work using an MCP2551 to generate ASYNC serial.
Ive not been successful in finding anyone or anyway to generate it, i must be searching using the wrong terms.

The mcp2551 i am using is on a breakout board ...so i am guessing someone must use them 'standalone' with an appropriate MPU.

Yes i may not be feeding the right thing in, certainly i found last night you connect them reverse to how i had thought.

This is the code with the pin out connections at the top https://github.com/SuperDroidRobots/CAN ... TE-242-001

i had it wired TX (software serial)to RX(mcp2551)
Today i have changed it to
- Hardware UART pin 0/1
- TX to TX , RX to RX

And will test the Vin to make sure its getting power.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 29 Nov 2015, 05:53

gcebiker wrote:I have not found anyone publishing their work using an MCP2551 to generate ASYNC serial.
And will test the Vin to make sure its getting power.


--Differential Async Serial.
--4.96v to mcp2551 breakout board (powered from plug pack)
--4.26 powered from USB.

MCP2551 operating voltage 4.5v-5.5v
http://www.superdroidrobots.com/shop/it ... kout/1841/
(mines not actually this one, its one from ebay as superdroid was out of stock)

...so found one culprit.
/remedy - run from plug pack when testing...and remember to disconnect USB to PC when doing so !
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 29 Nov 2015, 15:05

Now getting output and readings via the Saleae Logic 4 (when the Arduino is powered via wall power pack)

...not the entirely right output, but small steps forward.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 02 Dec 2015, 13:26

Not yet been able to get it going (the mpc2551) , i can get a stream of '255' of it, not sure what i am doing wrong.

Ordered a MAX485 break out...a sabertooth is much cheaper than going this route but having gone this far...meh, may as well keep going.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby Burgerman » 02 Dec 2015, 14:53

A sabretooth will work only for an empty chair. And then only if you can also do a lot of programming, and add motor compensation etc. Or it wont be controllable. Take a look at the detailed roboteq thread. We are fighting this issue still after 2 years!
User avatar
Burgerman
Site Admin
 
Posts: 70264
Joined: 27 May 2008, 21:24
Location: United Kingdom

Re: Arduino controlled wheelchair

Postby woodygb » 02 Dec 2015, 15:56

gcebiker wrote:Not yet been able to get it going (the mpc2551) , i can get a stream of '255' of it, not sure what i am doing wrong.

Ordered a MAX485 break out...a sabertooth is much cheaper than going this route but having gone this far...meh, may as well keep going.


I ... as you know ...avoided this by going the simpler route of having the Arduino provide joystick voltage signals to the pods board.

Should you not want the joystick or the plastic shroud you could ..apart from the All in One types ... throw a vast majority of the pods bulk away and reduce the components down to the pods main board/s and an Arduino with a suitable external interface that could be used as a "joystick".
An expert is a person who has made all the mistakes that can be made in a very narrow field.
Niels Bohr
User avatar
woodygb
 
Posts: 7128
Joined: 12 Mar 2011, 18:45
Location: Bedford UK

Re: Arduino controlled wheelchair

Postby gcebiker » 02 Dec 2015, 23:16

Its ok,

I have an
- ESP8266 wifi arduino development board.
- GcDuino , bluetooth/RF24 arduino board.
- The Woody BT driver module
- bunch of Arduino Nano's
- A freetronics 'UNO' type arduino

so i have the tools to add sensors (tho no sensors yet funnily enough) to the chair via the joystick, using woodys BT receiver as a start or other micro controllers to replicate it and add sensors.

I really want to find out how to generate Differential serial from an Arduino, i had looked into a MAX232 but that seems to step the voltages up.

I hope i am reading it right that the MAX485 chips just generate the differential serial.

The MCP2551 is supposed to do that also but it may be the way its on the development board the Rs pin is being pulled the wrong way (high/low/floating, instead of what ever i need).

A clean, factory joystick, factory bus line/plug - interface box to modify joy signals (if a wall is in front/side) will be nice and clean...once i work out how to talk to the Dynamic Shark - base motor driver.

Seeking to enhance the chairs function/safety

Its not like what i am trying to do is hard...its just i dont know how to do it (generate the differential serial signal)
In the mean time i have some L298N motor driver boards and a few TreX Pololu Motor driver boards to build up some differential drive models for use as test vehicles.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 11 Dec 2015, 11:24

MAX485 breakout boards arrived, data sheet looks promising.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 13 Dec 2015, 04:32

....insert 'doin a jig' emicon here.
Image
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 16 Dec 2015, 15:08

Got some unexpected help today.

Cant say much, but first off i need to power the High side at +12v 40ma for the Power base to 'wake up' .
This is reflected in the TTL code but ...its only 5ish volts not 12+

Pretty close on some stuff, doing more than i need to on other stuff.

I may not even need the 485 chip, thanks to softwareserial.h
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 21 Dec 2015, 14:10

I think i am going to need to order some more parts.

Arduino to generate the serial data, RS485 to convert to differential serial, 38400 baud,

next bit is getting me reading a lot,

I need an isolated RS485 transceiver (like a http://www.linear.com/product/LTC1535)
as the needed 12-24v spike for 300ms would fry the digital out on my MAX485 and possibly the Arduino too.

Could i just run the data lines thru an OptoCoupler ?

Anyone with some hires pics of the Shark Controller insides ? failing that i am going to have to open up the one i am sitting in and poke about to see how Dynamic did it.

I replaced some of the caps in my joystick that wore out, i wonder if thats how dynamic does it...just a capacitor discharge on the data lines...24v at 40ma is a pretty big cap tho and it would still fry the data lines, surely it could not be as easy a low capacitance ESD diode...
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby Burgerman » 21 Dec 2015, 14:15

as the needed 12-24v spike for 300ms would fry the digital out on my MAX485 and possibly the Arduino too.


Zener 4.7V diode to ground, and fed via a high value resistor. R5k? Then only 5V ever gets through.
User avatar
Burgerman
Site Admin
 
Posts: 70264
Joined: 27 May 2008, 21:24
Location: United Kingdom

Re: Arduino controlled wheelchair

Postby Irving » 23 Dec 2015, 13:19

Applying 12 - 24v to the high side, which, on those modules, has a 20k resistor to the +5v rail would indeed fry the max485 and quite possibly the arduino. The MAX485 chip receiver has a maximum common voltage of 12v so will need protecting. The isolated RS485 you link to still is limited to +14v common mode and has the additional complexity of needing a transformer/rectifier to power the isolated element, and its a bigger package. You still need a way to pull the high side up to a high voltage from the arduino so you'll lose that isolation unless you use an optoisolator, but then you could do that on the arduino side of the MAX485 anyway and would be less complex. How had you planned to deliver this 'high side' pulse? I can come up with a schematic if you need help.
C5/6 A (complete)
Puma 40, 75Ah LiFePO4 (pic is on tour @ Whistler, BC)
Puma 40 backup, 73Ah MK (for now)
Spectra Plus (weedy 40Ah MK)
User avatar
Irving
 
Posts: 2114
Joined: 04 Dec 2012, 11:51
Location: NW London

Re: Arduino controlled wheelchair

Postby gcebiker » 23 Dec 2015, 14:57

I am going to open up my controller again and just see how the pro's did it,

My power-chair controller (Dynamic Shark)is nearly 10years old and I've only ever had to replace one capacitor in it.
No point in reinventing the wheel if i don't have to.

I've been reading up on various methods, seems the new trend is solid state isolators,
here's one article http://www.digikey.com.au/Web%20Export/ ... directed=1

Or maybe a level shifter , not sure yet.

Doing a lot of work with the TReX from Pololu to do some other disabled assist stuff with Sailability,
If anyone's interested ive a page with the project info, great reading if you are having trouble sleeping,
The code is fairly well commented so hopefully is easy enough to follow.
http://sailabilitygc.org/trex-motor-dri ... er-assist/
I just wish Pololu had Arduino Libraries, that would make it a joy to work with.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 30 Dec 2015, 01:46

For anyone looking to use a Pololu TReX in their projects, i am posting here a copy of my code.

Tested and working, its incomplete as to the on the fly Current limit adjustments and other possible variables, also missing is the code for M3

But control of both motors M1 and M2 , the bidirectional ones has working code.
...this is not the thread for this but figure anyone looking at past posts is most likely to end up here anyway.

Ill finish assembly of this Mobility Project for Sailability this week and then will be able to get back into the Shark Joystick Bus emulator

The following code is only my second attempt at writing full code scripts, it is heavily notated for that reason.
There may well be better/more code efficient ways of writing the below, please use as a guide.

Code: Select all
/* written by Tony Matthews for the purpose of
Disabled assist sail winch control
in 303 and liberty Class Access dinghy's

One brushed bidirectional motor drives a main sheet winch,
One brushed bidirectional motor drives a jib sheet (liberty) or rudder (303's, 2.3's)
One brushed motor is a bilge pump, to empty any water that splashes in
Or operate signalling device, horn/light.

Code here in is written by Tony Matthews, whom has TBI.
TBI – Traumatic Brain Injury ...Use at your own risk.
For the benefit of Sailability Gold Coast, Queensland, Australia.

Serial.print is for testing.
tRexSerial.write is the software serial UART to communicate with the TReX.


Notes from Pololu's documentation.
--Motor Current codes --
Code needs one of each ie, current and current limit
0x13: motor 1 current limit (default: 0 – no motor 1 current limit)
0x14: motor 2 current limit (default: 0 – no motor 2 current limit)
0x15: motor 1 current limit proportionality constant P (default: 0x0A)
0x16: motor 2 current limit proportionality constant P (default: 0x0A)

--Acceleration Codes--
Acceleration used over 'set direction' as TReX has in built soft start/stop
Less wear on the winches to have soft starts.
Motor 1 - BiDirectional
0xC4 - Brake Low M1
0xC5 - Reverse M1
0xC6 - Forward M1
0xC7 - Brake low M1

Motor 2 - BiDirectional
0xCC - Brake Low M2
0xCD - Reverse M2
0xCE - Forward M2
0xCF - Brake Low M2

Motor 3 - Single direction only
0xF1 - Accelerate Motor M3

-- Motor speed settings --
May be represented as an integer as the Arduino converts it to HEX automatically (TReX reads HEX)
Must be positive number between 0-127
0 being stopped, 127 full speed
(Actual speed depends on acceleration logic and current draw V current limit)
eg M3 to full speed would be
tRexSerial.write(0xF1);  //M3
tRexSerial.write(127);  // full speed

All motor speed/direction/stopped need a speed value to go with them , eg stopped + 0 , forward + 127
*/


//Software serial settings
#include <SoftwareSerial.h>
const int rx = 7; // rx pin of Arduino, SO(serial out)of TRex.
const int tx = 8; // tx pin of Arduino, SI(serial in)of TRex.

SoftwareSerial tRexSerial (rx, tx); // RX to SO of Trex, TX to SI of Trex

// Pot inputs
// Main sheet M1
int mainPin = A0;  //input A0 for mainsheet
int mainVal = 511;  // int to hold main Input value,  start up in neutral 511
int mainValmapin;
int mainValmapout;

// Jib sheet M2
int jibPin = A1;
int jibVal = 511;
int jibValmapin;
int jibValmapout;


// dead band settings
int deadVal = 300;    // will change to pot values , one for each axis
int midVal = 511;
int fwdVal = (midVal + deadVal);
int revVal = (midVal - deadVal);

int zero = 0;    // integer for serial data '0' as 0 is ambiguous as used in a 'serial.write(0)'

// Power/speed variables
// Current limit (desired current limit in milliamp's / 150ma / 2 = ( )value)
// (rounded up) 2amps=7 , 10amps=33
int maxAmps = 2;//Current limit (desired current limit in milliamp's / 150ma / 2 = ( )value)
int overAmpbeh = 0; // over Amp limit behaviour 0=turn motor off
// data packet settings
unsigned char data[4];
unsigned long timer = 0;

void setup()
{
  delay (1000);
  tRexSerial.begin(19200);
  delay (400) ;    // wait for serial to start.

  // Write TReX Motor Settings/Behaviour.


  // build M1 data packet for current limit and proportionally constant
  // build M1 current limit packet
  {
    data[0] = (0x80);   // set parameter bit instruction
    data[1] = (0x07);   // TReX id number (if i had more than one, still necessary with only one)
    data[2] = (0x13);   // Parameter id, 0x13 for M1 Current Limit
    data[3] = (maxAmps);     // Current limit (desired current limit in milliamps / 150ma / 2 = ( )value)
    // eg, desired current limit 2amps, ergo 2000/150/2=6.66, rounded up to 7
    for (unsigned char i = 0; i < 4; i++)
      tRexSerial.write(data[i]);
  }
  delay(10);
  // build M1 Proportionally constant settings packet
  {
    data[0] = (0x80);   // set parameter bit instruction
    data[1] = (0x07);   // TReX id number (if i had more than one, still necessary with only one)
    data[2] = (0x15);   // Parameter id, 0x15 for M1 Proportionally constant current Limit (pccl)
    data[3] = (overAmpbeh);      // Behaviour of PCCL current limit // Proportionally constant 0 (turn motors off if over current)

    for (unsigned char i = 0; i < 4; i++)
      tRexSerial.write(data[i]);
  }
  delay(10);
  //Build M2 Parameter settings packets

  //M2 data packet for current limit
  {
    data[0] = (0x80);   // set parameter bit instruction
    data[1] = (0x07);   // TReX id number (if i had more than one, still necessary with only one)
    data[2] = (0x14);   // Parameter id, 0x14 for M2 Current Limit
    data[3] = (maxAmps);      // Current limit (desired current limit in milliamps / 150ma / 2 = ( )value)
    // eg, desired current limit 2amps, ergo 2000/150/2=6.66, rounded up to 7
    for (unsigned char i = 0; i < 4; i++)
      tRexSerial.write(data[i]);
  }
  delay(10);
  // Build M2 Proportionally constant settings packet
  {
    data[0] = (0x80);   // set parameter bit instruction
    data[1] = (0x07);   // TReX id number (if i had more than one, still necessary with only one)
    data[2] = (0x16);   // Parameter id, 0x15 for M1 Proportionally constant current Limit
    data[3] = (overAmpbeh);      // Behaviour of PCCL  Proportionally constant 0 (turn motors off if over current)

    for (unsigned char i = 0; i < 4; i++)
      tRexSerial.write(data[i]);
  }
  delay (10); // give tRex time to apply settings.

}
void loop () {
  // Main sheet control (M1)
  {
    mainVal = analogRead(mainPin);
    delay(10);

    if (mainVal > fwdVal)   // Forward M1
    {
      mainValmapout = map(mainVal, fwdVal, 1023, 0 , 127); // map speed to return int 0-127
      data [0] = (0xC6); // accelerate motor 1
      data [1] = (mainValmapout);   // Analog read val ,mapped.
      for (unsigned char i = 0; i < 2; i++)
        tRexSerial.write(data[i]);
    }
    else if (mainVal < revVal )  // Reverse M1
    {
      mainValmapin = map(mainVal, 0, revVal, 127 , 0); // map reverse speed to return int 0-127
      data [0] = (0xC5); //reverse accelerate motor 1
      data [1] = (mainValmapin); // Analog read val ,mapped.
      for (unsigned char i = 0; i < 4; i++)
        tRexSerial.write(data[i]);
    }
    else       // stop M1
      tRexSerial.write(0xC7);   // brake low
    tRexSerial.write(zero);   // zero integer value
  }

  //Jib sheet control (M2)
  {
    jibVal = analogRead(jibPin);
    delay(10);

    if (jibVal >= fwdVal)    // Forward M2
    {
      jibValmapout = map(jibVal, fwdVal, 1023, 0, 127); // map speed to return positive int 0-127
      data [0] = (0xCE); // accelerate motor 2 forward
      data [1] = (jibValmapout); // Analog read val, mapped.
      for (unsigned char i = 0; i < 2; i++)
        tRexSerial.write(data[i]);
    }

    else if (jibVal <= revVal )    // Reverse M2
    {
      jibValmapin = map(jibVal, 0, revVal, 127 , 0); // map reverse speed to return positive int 0-127
      data [0] = (0xCD); //reverse accelerate motor 2
      data [1] = (jibValmapin); // Analog read val ,mapped.
      for (unsigned char i = 0; i < 2; i++)
        tRexSerial.write(data[i]);
    }

    else   // brake M2
      tRexSerial.write(0xCF); // brake low
    tRexSerial.write(zero); // zero integer value

  }

}

http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 01 Jan 2016, 12:11

I thought the RS485 breakout board i had was rated to 12v Vcc...

So i figured wire up like this pic and see if the pulse high triggered the base to 'on' ...well i got a bit of white smoke.
There will be a delay while i wait for a new board, might get a few this time....i can see it happening again.

Image
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby LROBBINS » 07 Jan 2016, 18:58

If you can get by with 12V output (rather than needing 24 which might be iffy for what I'm about to suggest), consider using two gates of a 4066 (one with 15V max Vcc) - RS485 at the inputs, and "switch" closures for the outputs. This has the advantage of usually not having to worry about polarity of the output connections and requires few external components. You could even get fancy with some voltage dividers and perhaps using all 4 gates on one chip to get quite close to the differential signal of the Shark. The 4066 is not very fast, but neither is a wheelchair bus, and input-output isolation is very good IF you follow the notes in the data sheet with care.
Ciao,
Lenny
LROBBINS
 
Posts: 5789
Joined: 27 Aug 2010, 09:36
Location: Siena, Italy

Re: Arduino controlled wheelchair

Postby gcebiker » 08 Jan 2016, 13:42

new RS485 board got here today, ...and 15 more en route from Honk Kong

As the 485 break out board is rated at 12v i am hoping i can pulse it at 12v and get the base unit to turn on and start sending packets back to the Arduino.
...this time ill use a regulated 12v supply instead of the 'wall transformer' i used the first time. :?

I need to make some changes to the code also to wait for a packet to come back from the base before sending the next.
Also some coding for the Pot outputs for better low speed handling, but baby steps.

I am waiting to hear back from the 'Dangerous Prototypes' forum regarding if i can use the 'Bus Pirate' i purchased at the start of this exercise to act as an Oscilloscope.

I got burnt, when recently coding up the TReX from Pololu (in the extreme absence of any example code...), thinking my wiring was at fault when i just missed a line of code (which i was told looked like it should work... :?: ), but its all about learning, hooking up a Logic probe and/or Oscilloscope will clear things up a lot and rule out / in any coding/wiring errors.

I was thinking along the lines of a 4066 but to switch the data lines from the base to a 12v supply for 300ms then disconnect from that and connect to the output of the RS485

Ive plenty of fets here, ill be doing testing before subjecting the RS485 again, the Logic Analyser has four probes, well my version. Its a fantastic tool for 'seeing' what is going on.

From the looks of it the original Shark Joy does something similar, using 63v caps and other components.
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby gcebiker » 08 Jan 2016, 15:11

DG419 looks like it will be suitable, https://datasheets.maximintegrated.com/ ... -DG419.pdf
http://greenmobility.com.au/rc-wheelchair-controller/
My YouTube Ch -- https://www.youtube.com/user/gcebiker
User avatar
gcebiker
 
Posts: 879
Joined: 11 Jul 2015, 14:20
Location: Gold Coast, Queensland, Australia.

Re: Arduino controlled wheelchair

Postby Irving » 08 Jan 2016, 18:21

You like your esoteric parts :), however that does look a neat solution albeit not a cheap one at 4GBP for the Maxim part (DIP), but the equivalent Vishay part is only 1GBP (from RS)

gcebiker wrote:DG419 looks like it will be suitable, https://datasheets.maximintegrated.com/ ... -DG419.pdf
C5/6 A (complete)
Puma 40, 75Ah LiFePO4 (pic is on tour @ Whistler, BC)
Puma 40 backup, 73Ah MK (for now)
Spectra Plus (weedy 40Ah MK)
User avatar
Irving
 
Posts: 2114
Joined: 04 Dec 2012, 11:51
Location: NW London

PreviousNext

Return to Everything Powerchair

Who is online

Users browsing this forum: acid_coke, emilevirus, ricardoh, yeshelp and 75 guests

 

  eXTReMe Tracker