Dear,
we used to program microchip in C language.
we like to consider moving to flowcode.
before we buy, we downloaded the free version and it's looking good.
we do like to try one time to convert the C code to Flowcode but we can't do it on the free version.
can someone please convert this code for us so we can see how this function work and send to us?
our email is - info@Tomer-systems.com
the code is here below
'***********************************************************************
'* Name : XBee.BAS *
'* Author : Hadar Magali *
'* Date : 20-Aug-10 *
'* Version : 1.1 *
'* Notes : Concrete pump pulse counter, for De-Waalusing XBee *
'* Used Adrresses: * *
'* : *
'* Notice : Copyright (c) 2010 *
'***********************************************************************
'The metal detector is connected to RA4 (pin 6).
'
'The "Reverse" signal connevted to RA5 (pin 7).
'The "Reverse" signal is pulled down. It reverses counting while being high.
'
'Ther system sends the maximum reading (Max_Counting).
'
'The start counting is 100.
'
'Each 1.4 second, the RS232 transmits the Pulse_counter register(16 Bit).
'
'Baud rate of 9,469 (9,600), with 5,000,000 Hz cristal.
'
'The Pulse_Counter register low Byte is mirored to PIC PORTD.
'
'The massage is "(TT,TH,HU,TE,UN)" (without the ",")
'Where:
' "(" = (40 ASCII). Massage start
' "TT" = Tens of Thousents
' "TH" = THousents
' "HU" = HUndredss
' "TE" = TEns
' "UN" = UNits
' ")" = (41 ASCII).End of massage.
Pause 1000 'wait 1 seconds for XBee init
'Variables decleration
Pulse_counter var WORD
Max_Counting VAR WORD
Remaider VAR WORD
Tens_Thousents VAR Word
Tousents VAR Word
Hundreds VAR Word
Tens VAR BYTE
Singles VAR BYTE
Previos_state VAR BIT
Excisting_state VAR BIT
'Initiation (Enter)
trisa = 255 'pic port A input
trisc = 0 'pic port C output
trisd = 0 'pic port D output
ADCON1 = 6 'All pins are digital (no a/d).
spbrg = 32 'baud rate 9600 (32+1, high speed, 5,000,000 Hz => 9,469)
rcsta = 128 'set pin RC6/RX/CLK to RS232 Transmit
txsta = 36 'transmit enable, high speed
Pulse_counter = 100 'initiating counter to "zero" - 100
Max_Counting = 100 'Initiating Max-Counter to "zero" - 100
if (PORTA & 16) > 0 THEN
Excisting_state = 1
Else
Excisting_state = 0
ENDIF
Previos_state = Excisting_state
'Real program
Start_Over:
if (PORTA & 16) > 0 THEN
Excisting_state = 1
Else
Excisting_state = 0
ENDIF
IF Previos_state = Excisting_state Then Transmit ' If no pump pulse - transmit the
'Pulse_counter register as is
IF (PORTA & 32) > 0 THEN
Pulse_counter = Pulse_counter - 1 'If pump switch is in "Reverse" position, decrement
'Pulse_counter register by 1
ELSE
Pulse_counter = Pulse_counter + 1 'If pump switch is in "Normal" position, increment
'Pulse_counter register by 1
ENDIF
IF Pulse_counter > Max_Counting THEN
Max_Counting = Pulse_counter
ENDIF
Previos_state = Excisting_state
PORTD = Max_Counting // 256 'miroring Pulse_Counter low byte to PORTD
Transmit:
If (TXSTA & 2) = 0 THEN Transmit 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = 40 'Transmit delimiter caracter "(" = 28H = 40
Tens_Thousents = Max_Counting / 10000
Remaider = Max_Counting // 10000
Wait_1:
If (TXSTA & 2) = 0 THEN Wait_1 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = Tens_Thousents + 48 'Transmit Tens-Thousents digit of Pulse_counte in ASCII
Tousents = Remaider / 1000
Remaider = Remaider // 1000
Wait_2:
If (TXSTA & 2) = 0 THEN Wait_2 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = Tousents + 48 'Transmit Thousents digit of Pulse_counte in ASCII
Hundreds = Remaider / 100
Remaider = Remaider // 100
Wait_3:
If (TXSTA & 2) = 0 THEN Wait_3 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = Hundreds + 48 'Transmit hunderd digit of Pulse_counte in ASCII
Tens = Remaider / 10
Singles = Remaider // 10
Wait_4:
If (TXSTA & 2) = 0 THEN Wait_4 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = Tens + 48 'Transmit Tens digit of Pulse_counte in ASCII
Wait_5
If (TXSTA & 2) = 0 THEN Wait_5 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = Singles + 48 'Transmit Singles digit of Pulse_counte in ASCII
Wait_6:
If (TXSTA & 2) = 0 THEN Wait_6 'wait for UART
txsta = 4 'High speed
rcsta = 128 'serial port enable
txsta = 36 'transmit, high speed
txreg = 41 'end of massage "(" = 29H = 41
Pause 1400 'Wait 1.4 seconds - sends two massages per second.
goto Start_Over 'start a new rs232 massage.
thanks.
convert C code to Flowcode
-
HadarMagali
- Posts: 1
- http://meble-kuchenne.info.pl
- Joined: Wed May 27, 2026 3:42 pm
-
mnfisher
- Valued Contributor
- Posts: 2017
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 159 times
- Been thanked: 943 times
Re: convert C code to Flowcode
The code you present here isn't C - the convert function won't work.... we do like to try one time to convert the C code to Flowcode but we can't do it on the free version.
As a description of what you are trying to do - it looks straightforward to convert to flowcode - what have you attempted so far?
Martin