Electronics > Beginners

Assembly code Help! PIC16F57

<< < (22/32) > >>

KL27x:

--- Quote ---My question to is, Is it possible that problems could occur if the program is running to quickly?
--- End quote ---
No. If the servo is doing what it's supposed to, that is the only thing that has a speed limitation. The rest of the machine, AFAIK, has no speed limitation.


--- Quote ---how would we go about slowing it down?
--- End quote ---
The clock speed is set by the external crystal. You could use a slower crystal.

You could also try changing the program constants. Programming constants are often there for tuning things like speed/delays. By virtue of existing, constants are something the coder wanted easy access to in order to tweak/tune/adjust, himself. So while doing so will almost certainly not fix the bug, messing around with these constants might give you some insight into how the program works.

Ian.M:
If by servo you mean RC servo, the position they move to is set by the pulsewidth, so changing the MCU clock speed will change the position they move to (until the pulse repetition rate goes out of range) , not the actuation speed.   To control the speed of movement, the code would need to loop through intermediate positions rapidly enough and with a small enough position increment to cause the servo to move at a steady rate rather than driving to the new final position at its maximum motor speed.

At this point you have a much better understanding of what the code needs to do and how the hardware works than you did initially, and IMHO the optimum way forward, assuming the board has a socket for a DIP package PIC16x57, would be to design a pin compatible module with a modern PIC on it to let you rewrite the firmware without compromises  using a high level language e.g Microchip XC8.  With some thought given to choice of PIC and pinout allocation, you could probably have a dedicated ICSP/ICD header on the module allowing you to debug the new application in circuit, so you could pause execution at any time to examine/modify state variables etc.

Electrofinn:
@Kl27x yeah I thought as much. oh well. The ones in the "constants" list seem to be for just the reels, messing with some of them had some strange results like the reels would stop half way between one fruit and another lol one effects the altogether speed but as far as being able to control flashing speeds, I'm guessing they exist in there respective headers? 

@Ian.m yep, I agree. I am happy with how far we have come and I learnt new things on the way. completely re-doing it maybe something for me to aim for in future. 

KL27x:
To expand on what Ian said, there is perhaps the only way to make a servo move from position A to B faster is that it is a different brand of servo, it has less resistance to movement, or it is getting higher voltage. So what you are probably saying is that the servo pauses a shorter amount of time before moving to the next position.

If the crystal is the same frequency, the most likely reason for the "good" machine to run slightly slower is because  the code was changed and more instructions were added or are being executed per program loop. The average length of the program loop essentially determines the "program clock speed," due to how the code is structured. Many/most/all of the delays in this code are predicated off of main loop cycles.

So one might guess they had to add a significant amount of code to fix the bug.

Electrofinn:
I see what your saying now, yes there is less of a pause between actuations as compared to the original chip as opposed to the actuations themselves being quicker, that is to say the actuation speed is constant throughout but the pause is shorter.

If I am understanding this correctly, things like the led blink rate is a product of how many instructions exist in a given loop and not a changeable variable?


--- Quote ---So one might guess they had to add a significant amount of code to fix the bug.
--- End quote ---


maybe this might be what they were talking about when they said they did it with just 3 bytes to spare...perhaps.
 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod