|
Post by kennedylanduk on Oct 20, 2010 14:24:21 GMT
ok. Some more news.
I soldered everything else in place (checking the magical 5 volts at all times). Then programmed the pic and put in place.
Left it connected to a DC supply as I want to get it working there first. Now I can control the speed of the motor (it was like a eureka moment), but the motor direction does not change when I reverse the polarity.
I had not connected pins 6 and 7 on the L272. So I connected those, and get no life in the motor. If I lift pin 6 so it is not in the socket, I can control the speed again, but in one direction only.
I'm nearly finished on a 2nd decoder from scratch (all voltages correct) so will finish that and see if I get the same behaviour.
|
|
|
Post by kennedylanduk on Oct 20, 2010 14:57:37 GMT
Hmmm. 2nd build displays exactly the same behaviour.
Is that link right (pins 6 and 7 on the L272)?
|
|
|
Post by pahare on Oct 20, 2010 15:49:23 GMT
Works for me:-)))
|
|
|
Post by kennedylanduk on Oct 20, 2010 17:50:20 GMT
I cannot for the life of me see what I've done wrong. All the voltages are correct, and I can control the speed.
If pins 6 and 7 on the L272 are connected, I get nothing from the motor. If I lift pin 6 it turns one way, lift pin 7 it turns the other.
|
|
|
Post by pahare on Oct 20, 2010 18:21:56 GMT
I wasn't gloating, just saying mine is working (once I changed to 28 steps on the controller). Just a thought - do the volts on 5 & 8 of the L272 change when you reverse the supply volts? I'm using a SprogII in Throttle mode with JMRI. In forward pin5 is 4.97V and pin 8 is 3.19V referenced to 0V. In reverse pin 5 is 3.17V and pin 8 is 4.97V referenced to 0V. Both sets for the same throttle setting. My 5V is actually 4.97V. Hope this helps John
P.S. volts on pins 6 & 7 are 0.6V in either direction, and doesn't change with throttle setting. John
|
|
|
Post by kennedylanduk on Oct 20, 2010 18:59:09 GMT
I haven't connected up to a DCC controller yet, I want to get it working on DC as Paul suggested. All this is on a standard Hornby DC controller.
I'll try and measure the voltages coming out of the L272 tomorrow.
And my 5 volts is actually 4.9v (with my new cheap multimeter, old one has gone in the bin).
|
|
|
Post by pahare on Oct 21, 2010 10:49:26 GMT
I've just tested mine on a 12 V DC supply. The motor did not run, and when I reversed polarity, it still did not run. Voltage on pin 5 was 0.98, and on pin 8 was also 0.98, and stayed the same when I reversed supply polarity. Volts on pin 6/7 was 0.6. 5V was 4.97. Interestingly, when I put the DVM probes between 0V and pin 5 the motor ran very slowly and when I put it on pin 8 it ran the other way as slowly (I judged). I don't know if this helps but suggests to me that the decoder won't work on DC, since mine runs on DCC o.k.
|
|
|
Post by kennedylanduk on Oct 21, 2010 18:08:08 GMT
What happens if you lift pin 6 or 7 on the L272M on DC?
|
|
|
Post by pahare on Oct 21, 2010 18:11:07 GMT
Can't do that easily as the link is soldered in - sorry.
|
|
|
Post by kennedylanduk on Oct 21, 2010 19:03:27 GMT
No worries. My L272s are all in sockets so easy to just pull out and lift a pin.
I'll measure some voltages tomorrow if I get the time and try it on a DCC decoder.
|
|
|
Post by pahare on Oct 22, 2010 10:00:30 GMT
My 272 is in a socket too. Hadn't thought of bending pins, worried about breaking them off, but I suppose once or twice won't hurt - anyway I've got some spares.
Results using a 9V battery : Both pins down (normal) motor won't run. Pin 6 up - motor runs cw which ever way battery is connected. Pin 7 up - motor runs ccw which ever way battery is connected.
HTH John
|
|
|
Post by kennedylanduk on Oct 22, 2010 12:31:19 GMT
This is exactly the same behaviour I see on DC.
On DCC, did you need to program the decoder before using it (ie, program it to respond on address 3 (not program the pic chip))?
|
|
|
Post by pahare on Oct 22, 2010 13:49:35 GMT
No, it's pre-configured to address 3. In the zip file there is an excel file of the CVs and what they are set to - although I found CV 9 was set to 0 rather than 160 (not that it made much difference when I changed it). When I tried it on my NCE it wouldn't respond until I changed the NCE steps to 28 from 128. Same with my SprogII which also defaults to 128 steps - had to change that too in Decoderpro. Is that something you can set in the Hornby? I don't anything about the Hornby DCC stuff.
|
|
|
Post by kennedylanduk on Oct 22, 2010 13:56:55 GMT
I've never played with the speed steps before, but the manual says I can change it.
Does this change it on the decoder itself?
|
|
|
Post by pahare on Oct 22, 2010 14:03:37 GMT
As I understand it from posts elsewhere on this Forum the decoder only responds to 28 steps so you have to set your command station (i.e. Hornby) to match. That's what I have had to do.
|
|
|
Post by kennedylanduk on Oct 22, 2010 14:16:41 GMT
I'm so close now that I'm starting to get excited.
Changed it to 28 steps and it worked - briefly. The motor soon slowed down and stopped. The L272 chip got very hot. Both decoders I have behaved the same way.
Any idea why this would happen?
|
|
|
Post by pahare on Oct 22, 2010 14:33:25 GMT
I think the 272 can go into thermal shutdown, so if its getting hot that's maybe why the motor stops, but why is the 272 getting hot?? What motor are you using? Can you measure the current it takes on DC? It could be the motor load is too great for the 272.
|
|
|
Post by Paul Harman on Oct 22, 2010 14:35:06 GMT
I would be inclined to look at adjusting CV9. The L272 chip has built in thermal overload protection so should shut down before it gets too hot, but from my testing with a Lima loco (pancake motor) it would not run well on the default setting which I suspect was causing the motor to draw a high current while turning slowly. Adjusting CV9 resulted in everything runnning smoother and cooler.
I cannot remember which value I ended up with. Adjusting CV9 should go from low torque and quiet at the default setting to high torque and noisey at the other end of the setting range. It is possible that at the low torque end there is not even enough torque to turn the motor.
|
|
|
Post by pahare on Oct 22, 2010 15:21:54 GMT
I've just tried adjusting CV 9. My original setting was the default 160. The motor would start at step 10 or 11 but was easy to stall, even at full throttle, I set CV9 to 167 and the motor started at step 3, and was difficult to stall. I tried reducing CV 9 and have settled on a value of 164 as a compromise between low speed noise and good torque. Both motor and L 272 run cool. I think maybe this is the answer to kennedylanduk's final problem. Thanks Paul,
John
|
|
|
Post by kennedylanduk on Oct 22, 2010 16:06:32 GMT
It is possible to change these CV values in the ASM file? It doesn't look like the Hornby select can change CV values.
Tony.
|
|
|
Post by kennedylanduk on Oct 22, 2010 16:25:41 GMT
I've found this section. ;***************** User definable variables in this block *********************************** #define cv9default B'10100000' ; the last three bits determine the PWM. Default to 2kHz ; ^^^ ; Bit pattern PWM time PWM frequency ; 000 512us -> 2kHz ; 001 1ms -> 1kHz ; 010 2ms -> 500Hz ; 011 4ms -> 250Hz ; 100 8ms -> 125Hz ; 101 16ms -> 62Hz ; 110 32ms -> 31Hz ; 111 64ms -> 15Hz But I don't really understand what I should change the "10100000" to. Any ideas? Tony.
|
|
|
Post by kennedylanduk on Oct 22, 2010 17:06:32 GMT
I haven't got the hang of this.
I got the Hornby Elite out (which can change CV values). I wanted to avoid using it until I was sure the decoder was working with the Select (the Elite was much more expensive). Followed the instructions and changed CV9 to 164. Now the motor will not work.
Any ideas what I've done wrong?
|
|
|
Post by Paul Harman on Oct 23, 2010 8:17:17 GMT
You might like to try adjusting CV9 in the PIC programmer. CV9 is in EEPROM location 5. You should be able to change it from A0 in steps up to A7 (160-167 in HEX).
I would be inclined to start with A0 then move up in steps of 1 to see what hapens.
|
|
|
Post by kennedylanduk on Oct 23, 2010 11:01:54 GMT
Thanks Paul.
Just before I jump in and attempt things, when I read the PIC back, I get the following in the EEPROM data.
03 14 01 01 C8 00 00 02 14 FF FF FF FF FF FF FF ... FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF AA
So do I change the C8 or 00 (I don't know if it's zero indexed).
I'd prefer to modify the assembly and re-compile. Now that I'm so close to having it working properly, I'd like to get stuck into the code and see if I can get to grips with what's in there (I've never programmed a PIC before, but I can program in C/C++/Java/VB etc etc).
I've found the area of code "ChkPowerUp". If I modify things around
clrf MYEEDATA movlw CV19adr call EEPROM_WRITE movlw CV9adr ; CV9=0 i.e. 2kHz default call EEPROM_WRITE that should do it shouldn't it?
Tony.
|
|
|
Post by Paul Harman on Oct 23, 2010 11:32:42 GMT
That bit of code loads zero and writes it to a whole load of CVs, so probably needs correcting anyway to put the correct default value in CV9. That said I am not aware of anything that uses the uper five bits of CV9.
You need to bear in mind that the defaults are only written to the CVs during a factory reset, and I think that 160 (A0 in hex) is the best default to use, and it should only be changed if this value proves to be no good.
The values are zero indexed so you need to change the 'A4' one. CV9 is currently set to 164 in this instance, which is presumably what you programmed with the Elite. A good indication that something is working.
|
|
|
Post by kennedylanduk on Oct 23, 2010 11:44:45 GMT
Thanks Paul.
I've tried a few different values. A4 seems to be a good compromise as John found out. A0 and the motor was really slow, A7 it juddered around and was not smooth at all.
The chip still gets hot, but nowhere near as fast as it used to. I'm still a little concerned about the heat as these are all for my son's layout (and he likes to run things fast and continually).
But I have it working!!!! You could say I'm a little happy today!!
A few more questions.
1. What do these changes actually do (is there a WIKI or good explanation somewhere on the web that can help me)? 2. Are there any other values to change that might help with the heat?
Tony.
|
|
|
Post by Paul Harman on Oct 23, 2010 17:04:12 GMT
The L272 is good for 1.6A, so as long as your motor is drawing less than that it should be OK. It has thermal shutdown which will limit the current further if it gets too hot.
Adjusting CV9 is the only way of improving the heat efficiency. You will probably find that it runs cooler the faster the motor runs so I should not worry too much about anyone running flat out. The biggest risk is probably of frying the motor at low speed if CV9 is not optimised.
Changing CV9 changes the PWM frequency, which in simple terms is adjusting the length of pulse that is applied to the motor. CV9 =160 will give 2000 pulses per second, 161 will give 1000 pulses, 162 will give 500, 163 will give 250 and so on.
At low speed settings the pulses can be very short indeed and the inductance of the motor can result in sufficient shift of the voltage peak away from the current peak of the waveform that the pulse only exists long enough for there to be a high current flowing, but not long enough for sufficient voltage to build up. This of course will result in high current flowing, but the motor does not turn, and virtually all of the power will be dissipated in the L272 - hence low torque and a hot chip. Lowering the PWM frequency by increasing CV9 doubles the length of pulse for a given speed. The downside is that as you lower the PWM frequency the gaps between the pulses increase as well, and you will get the effect of the motor being turned on and off which will make it growl a bit at the PWM frequency.
That said, you should have little trouble finding a suitable setting for CV9 that will match the performance of your motor. At the ideal setting you will have both maximum torque and minimum growl - settings either side will result in either lower torque or more noise.
More advanced decoders have ways of getting round these problems, with things like adaptive PWM frequency so that the PWM frequency is lower at low speed settings to give a higher starting torque, BEMF where the motor is given more power to start and the motor speed is monitored so that the power can be reduced once it is up to speed and dither so that a lower PWM frequency than is ideal can be used without a noticable growl. Dither and adaptive PWM can be implemented in software (if anyone wants to have a go!) but BEMF requires more electronics as well and will make the decoder a lot bigger.
Not sure if there is a wiki for this though.
|
|
|
Post by kennedylanduk on Oct 23, 2010 17:23:03 GMT
Thanks Paul, it makes sense now.
I really intend getting into the software at some point in the next couple of weeks. Just need to learn a bit more (I'm finding my way through Penfold's introduction to PIC microcontrollers at the moment).
|
|