Help

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
buvaylov
Posts: 10
Joined: Wed Sep 30, 2020 5:27 am
Contact:

Help

Post by buvaylov »

Hello! I ask for help in the correct construction of the program based on ready-made macros.
1. "keypad" sets the number of turns, then switches to setting the wire diameter
2. The calculation of the values ​​of the step per shaft revolution
3. Go to "Step"
4. Counting of revolutions at the input "kl" (variable "number") and completion of work upon reaching the specified number of turns
Sorry for the machine translation. Thanks in advance, Alexander
Attached project
Attachments
Rezerv.rar
(5.19 KiB) Downloaded 124 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Help

Post by chipfryer27 »

Hi

I have downloaded your project and in the "Count_Stepper18" chart and I think you have a couple of things to check.

First is that you have the chip running on it's internal oscillator at 4MHz but you have no "C-code" in your chart to enable this. Although under Build > Project Options > Configure where you set parameters, you have set the clock to INTOSC I/O you still need to set the associated register in a C-code block.

Fortunately Flowcode makes this easy. If you click on Runtime and select the IntOsc Helper a new component will be added to the 2D control panel. Right click and in the properties you will find options to choose your speed. Type in your target speed (4000000). In the Code box you then have the necessary C-code to set the register. Simply copy this code (PCONbits.OSCF = 1;) I have shown the generated code inside brackets as an example, do not put the code in brackets

Next, at the very beginning of your chart place a C-Code component. This should be the first component in the chart. In Properties you can either delete the first three lines or start on line 4. Personally I prefer to delete the first three. Paste the code generated by the helper (PCONbits.OSCF = 1;) Remember no brackets.

That's it. The chip will be configured to run from the internal oscillator at 4MHz and if you wish you can now delete the IntOsc Helper from the dashboard.

Next, is probably a "Typo". You have cleared the LCD display before enabling it. Swap the Clear and Start components over. Depending on your LCD it may need a little time from enabling to being functional so it can be a good idea to have a short delay after Start of perhaps 50mS or so.

I have made these changes and included in the attached.

When simulating, the count increases when the button is pressed and the stepper moves one position. When the switch is thrown each press of the button decreases the count and the stepper reverses one position.

Hope this helps and let us know how you get on.

Regards
Attachments
count_stepper18_revers_v6_Test.fcfx
(16.86 KiB) Downloaded 117 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Help

Post by chipfryer27 »

Hi

In your other program, TransStan_ATMEGA8, I'm not really sure I understand what you are trying to achieve.

Your program seems to set a few variables then jumps to a Macro. Within that Macro you have a Loop but no apparent way to exit the Loop. Also, you have used the LCD component Macro "Start" numerous times. You don't need to do that. You only need to do this once near the beginning of your Main chart to initialise the LCD.

If you can explain in better detail what you are trying to do I can maybe help better.

Regards

Post Reply